diff options
author | Dominique Louis <savagesoftware@gmail.com> | 2017-04-12 17:54:13 +0300 |
---|---|---|
committer | Dominique Louis <savagesoftware@gmail.com> | 2017-04-13 23:00:08 +0300 |
commit | 196c3a6164eb1ed472cebb500ce9e7c51198282f (patch) | |
tree | ed9e746e8ee3ef4e55c7a115f7ccac4241f3e01f /Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs | |
parent | 314fdc7d71bcd95edc4c5323ea92df32058c31ac (diff) |
Refactor to support native CGPoint type.
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs')
-rw-r--r-- | Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs index f4f0a79..87d2592 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs @@ -13,14 +13,14 @@ namespace Xamarin.PropertyEditing.Mac internal NSTextField XEditor { get; set; } internal NSTextField YEditor { get; set; } - internal new PointPropertyViewModel ViewModel { - get { return (PointPropertyViewModel)base.ViewModel; } + internal new PropertyViewModel<CGPoint> ViewModel { + get { return (PropertyViewModel<CGPoint>)base.ViewModel; } set { base.ViewModel = value; } } public PointEditorControl () { - var xLabel = new NSTextView (new CGRect (0, 0, 20, 20)) { + var xLabel = new NSTextView (new CGRect (0, -5, 25, 20)) { Value = "X:", }; @@ -28,17 +28,17 @@ namespace Xamarin.PropertyEditing.Mac XEditor.BackgroundColor = NSColor.Clear; XEditor.StringValue = string.Empty; - var yLabel = new NSTextView (new CGRect (75, 0, 20, 20)) { + var yLabel = new NSTextView (new CGRect (85, -5, 25, 20)) { Value = "Y:", }; - YEditor = new NSTextField (new CGRect (80, 0, 50, 20)); + YEditor = new NSTextField (new CGRect (110, 0, 50, 20)); YEditor.BackgroundColor = NSColor.Clear; YEditor.StringValue = string.Empty; // update the value on 'enter' XEditor.Activated += (sender, e) => { - ViewModel.Value = new Point (XEditor.IntValue, YEditor.IntValue); + ViewModel.Value = new CGPoint (XEditor.IntValue, YEditor.IntValue); }; AddSubview (xLabel); @@ -49,7 +49,7 @@ namespace Xamarin.PropertyEditing.Mac protected override void HandlePropertyChanged (object sender, System.ComponentModel.PropertyChangedEventArgs e) { - if (e.PropertyName == nameof (PointPropertyViewModel.Value)) { + if (e.PropertyName == nameof (PropertyViewModel<CGPoint>.Value)) { UpdateModelValue (); } } @@ -57,8 +57,8 @@ namespace Xamarin.PropertyEditing.Mac protected override void UpdateModelValue () { base.UpdateModelValue (); - XEditor.IntValue = ViewModel.Value.X; - YEditor.IntValue = ViewModel.Value.Y; + XEditor.IntValue = (int)ViewModel.Value.X; + YEditor.IntValue = (int)ViewModel.Value.Y; } protected override void HandleErrorsChanged (object sender, System.ComponentModel.DataErrorsChangedEventArgs e) |