diff options
Diffstat (limited to 'Xamarin.PropertyEditing.Mac')
4 files changed, 52 insertions, 17 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs index 602bf7e..cf6914e 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs @@ -1,10 +1,7 @@ using System; using System.Collections; using System.Diagnostics; -using System.Drawing; using AppKit; -using CoreGraphics; -using Foundation; using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac diff --git a/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs index d889242..00801d8 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs @@ -1,10 +1,12 @@ using System; using System.Drawing; using CoreGraphics; +using Xamarin.PropertyEditing.Drawing; namespace Xamarin.PropertyEditing.Mac { - internal class PointEditorControl : BasePointEditorControl<Point> + internal abstract class PointEditorControl<T> : BasePointEditorControl<T> + where T : struct { public PointEditorControl () { @@ -19,6 +21,18 @@ namespace Xamarin.PropertyEditing.Mac YEditor.Frame = new CGRect (110, 0, 50, 20); } + protected override void UpdateAccessibilityValues () + { + XEditor.AccessibilityEnabled = XEditor.Enabled; + XEditor.AccessibilityTitle = ViewModel.Property.Name + " X Editor"; // TODO Localization + + YEditor.AccessibilityEnabled = YEditor.Enabled; + YEditor.AccessibilityTitle = ViewModel.Property.Name + " Y Editor"; // TODO Localization + } + } + + internal class SystemPointEditorControl : PointEditorControl<Point> + { protected override void UpdateValue () { XEditor.StringValue = ViewModel.Value.X.ToString (); @@ -29,14 +43,19 @@ namespace Xamarin.PropertyEditing.Mac { ViewModel.Value = new Point (XEditor.IntValue, YEditor.IntValue); } + } - protected override void UpdateAccessibilityValues () + internal class CommonPointEditorControl : PointEditorControl<CommonPoint> + { + protected override void UpdateValue () { - XEditor.AccessibilityEnabled = XEditor.Enabled; - XEditor.AccessibilityTitle = ViewModel.Property.Name + " X Editor"; // TODO Localization + XEditor.StringValue = ViewModel.Value.X.ToString (); + YEditor.StringValue = ViewModel.Value.Y.ToString (); + } - YEditor.AccessibilityEnabled = YEditor.Enabled; - YEditor.AccessibilityTitle = ViewModel.Property.Name + " Y Editor"; // TODO Localization + protected override void OnInputUpdated (object sender, EventArgs e) + { + ViewModel.Value = new CommonPoint (XEditor.IntValue, YEditor.IntValue); } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/SizeEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/SizeEditorControl.cs index 29495fb..9477016 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/SizeEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/SizeEditorControl.cs @@ -1,10 +1,12 @@ using System; using System.Drawing; using CoreGraphics; +using Xamarin.PropertyEditing.Drawing; namespace Xamarin.PropertyEditing.Mac { - internal class SizeEditorControl : BasePointEditorControl<Size> + internal abstract class SizeEditorControl<T> : BasePointEditorControl<T> + where T : struct { public SizeEditorControl () { @@ -19,6 +21,15 @@ namespace Xamarin.PropertyEditing.Mac YEditor.Frame = new CGRect (155, 0, 50, 20); } + protected override void UpdateAccessibilityValues () + { + XEditor.AccessibilityTitle = ViewModel.Property.Name + " Width Editor"; // TODO Localization + YEditor.AccessibilityTitle = ViewModel.Property.Name + " Height Editor"; // TODO Localization + } + } + + internal class SystemSizeEditorControl : SizeEditorControl<Size> + { protected override void UpdateValue () { XEditor.StringValue = ViewModel.Value.Width.ToString (); @@ -29,11 +40,19 @@ namespace Xamarin.PropertyEditing.Mac { ViewModel.Value = new Size (XEditor.IntValue, YEditor.IntValue); } + } - protected override void UpdateAccessibilityValues () + internal class CommonSizeEditorControl : SizeEditorControl<CommonSize> + { + protected override void UpdateValue () { - XEditor.AccessibilityTitle = ViewModel.Property.Name + " Width Editor"; // TODO Localization - YEditor.AccessibilityTitle = ViewModel.Property.Name + " Height Editor"; // TODO Localization + XEditor.StringValue = ViewModel.Value.Width.ToString (); + YEditor.StringValue = ViewModel.Value.Height.ToString (); + } + + protected override void OnInputUpdated (object sender, EventArgs e) + { + ViewModel.Value = new CommonSize (XEditor.IntValue, YEditor.IntValue); } } } diff --git a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs index f095ae5..28ac845 100644 --- a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs +++ b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs @@ -166,10 +166,10 @@ namespace Xamarin.PropertyEditing.Mac {typeof (PropertyViewModel<CoreGraphics.CGRect>), typeof (CGRectEditorControl)}, {typeof (PredefinedValuesViewModel<>), typeof(PredefinedValuesEditor<>)}, {typeof (PropertyViewModel<CoreGraphics.CGSize>), typeof (CGSizeEditorControl)}, - {typeof (PropertyViewModel<Point>), typeof (PointEditorControl)}, - {typeof (PropertyViewModel<CommonPoint>), typeof (PointEditorControl) }, - {typeof (PropertyViewModel<Size>), typeof (SizeEditorControl)}, - {typeof (PropertyViewModel<CommonSize>), typeof (SizeEditorControl) }, + {typeof (PropertyViewModel<Point>), typeof (SystemPointEditorControl)}, + {typeof (PropertyViewModel<CommonPoint>), typeof (CommonPointEditorControl) }, + {typeof (PropertyViewModel<Size>), typeof (SystemSizeEditorControl)}, + {typeof (PropertyViewModel<CommonSize>), typeof (CommonSizeEditorControl) }, {typeof (PropertyViewModel<Rectangle>), typeof (RectangleEditorControl)} }; } |