diff options
author | Dominique Louis <savagesoftware@gmail.com> | 2018-03-29 18:38:16 +0300 |
---|---|---|
committer | Dominique Louis <savagesoftware@gmail.com> | 2018-03-29 19:22:36 +0300 |
commit | fc38fa86bc575b731b978c199d5bbd4f3acbb070 (patch) | |
tree | 8e32acb4b89888735e43fc748b2500bea7738388 /Xamarin.PropertyEditing.Mac/Controls | |
parent | b032c2582df5310a497356c5c072ab93af59a181 (diff) |
Change to allow NumericEditor to handle nullables.
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls')
-rw-r--r-- | Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs | 15 | ||||
-rw-r--r-- | Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs | 6 |
2 files changed, 18 insertions, 3 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs index 22213e1..e0cae3a 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs @@ -62,6 +62,12 @@ namespace Xamarin.PropertyEditing.Mac set { SetValue (value); } } + public string StringValue + { + get { return numericEditor.StringValue; } + set { SetValue (value); } + } + public bool Wrap { get { return stepper.ValueWraps; } set { stepper.ValueWraps = value; } @@ -239,8 +245,13 @@ namespace Xamarin.PropertyEditing.Mac void SetValue (string value) { //Regulates maximun and minium out of range - stepper.DoubleValue = CoerceValue (FieldValidation.FixInitialValue (value, Value.ToEditorString ()).ToEditorDouble ()); - numericEditor.StringValue = FieldValidation.RoundDoubleValue (stepper.DoubleValue.ToEditorString (), NumericMode == ValidationType.Decimal ? FieldValidation.DefaultXcodeMaxRoundDigits : 0); + if (!string.IsNullOrEmpty (value)) { + stepper.DoubleValue = CoerceValue (FieldValidation.FixInitialValue (value, Value.ToEditorString ()).ToEditorDouble ()); + numericEditor.StringValue = FieldValidation.RoundDoubleValue (stepper.DoubleValue.ToEditorString (), NumericMode == ValidationType.Decimal ? FieldValidation.DefaultXcodeMaxRoundDigits : 0); + } else { + stepper.StringValue = value; + numericEditor.StringValue = value; + } } public void SetValue (double value) diff --git a/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs index 42f1257..5241742 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs @@ -105,7 +105,11 @@ namespace Xamarin.PropertyEditing.Mac protected override void UpdateValue() { - NumericEditor.Value = (double)Convert.ChangeType ((ViewModel).Value, typeof(double)); + if (underlyingType != null) { + NumericEditor.StringValue = ViewModel.Value == null ? string.Empty : ViewModel.Value.ToString (); + } else { + NumericEditor.Value = (double)Convert.ChangeType (ViewModel.Value, typeof (double)); + } } protected override void UpdateAccessibilityValues () |