Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadalyn Coryea <madalyn.coryea@xamarin.com>2017-02-11 01:05:32 +0300
committerMadalyn Coryea <madalyn.coryea@xamarin.com>2017-02-11 01:05:32 +0300
commit2337fd651222e911f1e1d266517ff82df727d0d6 (patch)
treeb3f88ebc263a1ce62a0ce0c05aa0498d4fcfe2c1 /Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs
parent04dce9e11b9519e6bfcf243aa6090bde90d3e929 (diff)
Added error handling for StringEditorControl
Organized the code so that the signaling of the errors happens in the base PropertyEditorControl class. Each subclass can override how errors can be displayed. This can be moved to the base class later on, depending on how we want to display errors in the future. This means we will most likely have to convert PropertyEditorControl back from being an Abstract class, and make its methods virtual. Right now to display an error, the editor turns red and all relevant errors are outputted to the console. Once we decide what we want our error-reporting system to look like, we can modifiy what we have now to be that.
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs')
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs12
1 files changed, 12 insertions, 0 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs
index 853b089..d0cff6d 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections;
using AppKit;
using Xamarin.PropertyEditing.ViewModels;
@@ -25,11 +26,22 @@ namespace Xamarin.PropertyEditing.Mac
viewModel = value;
UpdateModelValue ();
viewModel.PropertyChanged += HandlePropertyChanged;
+
+ // FIXME: figure out what we want errors to display as (tooltip, etc.)
+ viewModel.ErrorsChanged += (object sender, System.ComponentModel.DataErrorsChangedEventArgs e) => {
+ UpdateErrorsDisplayed (viewModel.GetErrors (viewModel.Property.Name));
+ };
}
}
protected abstract void UpdateModelValue ();
protected abstract void HandlePropertyChanged (object sender, System.ComponentModel.PropertyChangedEventArgs e);
+
+ /// <summary>
+ /// Update the display with any errors we need to show or remove
+ /// </summary>
+ /// <param name="errors">The error messages to display to the user</param>
+ protected abstract void UpdateErrorsDisplayed (IEnumerable errors);
}
}