diff options
3 files changed, 38 insertions, 4 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs index 6a8b213..7520f31 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs @@ -1,8 +1,11 @@ using System; using System.Collections; using System.ComponentModel; +using System.Threading; +using System.Threading.Tasks; using AppKit; using CoreGraphics; +using Foundation; using Xamarin.PropertyEditing.Drawing; using Xamarin.PropertyEditing.ViewModels; @@ -26,15 +29,41 @@ namespace Xamarin.PropertyEditing.Mac public override void KeyDown (NSEvent theEvent) { - if (theEvent.KeyCode == 36 || theEvent.KeyCode == 49) { + if (theEvent.KeyCode == (ushort)NSKey.Space) { MouseDown (theEvent); - } - else { + } else { base.KeyDown (theEvent); } } } + internal class ColorPopOverDelegate : NSPopoverDelegate + { + private BrushTabViewController brushTabViewController; + private CommonBrushType selectedBrushType = CommonBrushType.None; + + internal ColorPopOverDelegate (BrushTabViewController brushTabViewController) + { + if (brushTabViewController == null)
+ throw new ArgumentNullException (nameof (brushTabViewController)); + + this.brushTabViewController = brushTabViewController; + } + + public override void WillShow (NSNotification notification) + { + if (this.brushTabViewController.ViewModel != null) { + var ct = new CancellationTokenSource (); + Task.Factory.StartNew (()=> { + if (this.selectedBrushType == CommonBrushType.None) + this.selectedBrushType = this.brushTabViewController.ViewModel.SelectedBrushType; + else + this.brushTabViewController.ViewModel.SelectedBrushType = this.selectedBrushType; + }, ct.Token, TaskCreationOptions.None, TaskScheduler.FromCurrentSynchronizationContext ()); + } + } + } + internal class BrushEditorControl : PropertyEditorControl<BrushPropertyViewModel> { public BrushEditorControl (IHostResourceProvider hostResources) @@ -52,6 +81,8 @@ namespace Xamarin.PropertyEditing.Mac } }; + this.popover.Delegate = new ColorPopOverDelegate (this.brushTabViewController); + this.popUpButton = new ColorPopUpButton { ControlSize = NSControlSize.Small, Font = NSFont.SystemFontOfSize (NSFont.SystemFontSizeForControlSize (NSControlSize.Small)), diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs index e259878..88b508a 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs @@ -18,6 +18,8 @@ namespace Xamarin.PropertyEditing.Mac return false; } + public override bool IsFlipped => true; + public override void OnViewModelChanged (MaterialDesignColorViewModel oldModel) { base.OnViewModelChanged (oldModel); diff --git a/Xamarin.PropertyEditing/Drawing/CommonBrushType.cs b/Xamarin.PropertyEditing/Drawing/CommonBrushType.cs index cb1e8e8..376fc14 100644 --- a/Xamarin.PropertyEditing/Drawing/CommonBrushType.cs +++ b/Xamarin.PropertyEditing/Drawing/CommonBrushType.cs @@ -9,6 +9,7 @@ namespace Xamarin.PropertyEditing.Drawing MaterialDesign, Gradient, Tile, - Resource + Resource, + None } } |