diff options
author | Larry Ewing <lewing@gmail.com> | 2018-05-16 22:57:51 +0300 |
---|---|---|
committer | Larry Ewing <lewing@microsoft.com> | 2018-07-16 22:05:49 +0300 |
commit | be3e495b986db4eb09ecd206718a7455d581a765 (patch) | |
tree | f1296328421811cd91727a8311f6b7a26200c16e | |
parent | 5341f42f329b343486569cd7cc93f0f7d72be1fd (diff) |
Formatting fixes
23 files changed, 178 insertions, 198 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs index f89364f..03cc76a 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.ComponentModel; using AppKit; @@ -12,8 +12,6 @@ namespace Xamarin.PropertyEditing.Mac { internal class ColorPopUpButton : NSPopUpButton { - public NSPopover Popover { get; set; } - public ColorPopUpButton () : base () { } @@ -26,14 +24,16 @@ namespace Xamarin.PropertyEditing.Mac { } + public NSPopover Popover { get; set; } + public override void MouseDown (NSEvent theEvent) { if (Popover == null) return; - + Popover?.Show (new CGRect (20, this.Frame.Height / 2 - 2.5, 5, 5), this, NSRectEdge.MinYEdge); } - } + } internal class BrushEditorControl : PropertyEditorControl { @@ -56,7 +56,7 @@ namespace Xamarin.PropertyEditing.Mac popupButtonList = new NSMenu (); popUpButton.Menu = popupButtonList; - this.DoConstraints (new[] { + this.DoConstraints (new [] { popUpButton.ConstraintTo (this, (pub, c) => pub.Width == c.Width - 34), popUpButton.ConstraintTo (this, (pub, c) => pub.Height == DefaultControlHeight + 1), popUpButton.ConstraintTo (this, (pub, c) => pub.Left == c.Left + 4), @@ -68,10 +68,9 @@ namespace Xamarin.PropertyEditing.Mac UpdateTheme (); } - internal new BrushPropertyViewModel ViewModel - { - get => (BrushPropertyViewModel)base.ViewModel; - set => base.ViewModel = value; + internal new BrushPropertyViewModel ViewModel { + get => (BrushPropertyViewModel)base.ViewModel; + set => base.ViewModel = value; } readonly ColorPopUpButton popUpButton; @@ -115,7 +114,7 @@ namespace Xamarin.PropertyEditing.Mac break; default: if (ViewModel.Value == null) - title = "null"; + title = "null"; break; } @@ -123,7 +122,7 @@ namespace Xamarin.PropertyEditing.Mac return title; } - protected override void UpdateValue () + protected override void UpdateValue () { SetEnabled (); this.brushTabViewController.ViewModel = ViewModel; @@ -148,5 +147,5 @@ namespace Xamarin.PropertyEditing.Mac { UpdateValue (); } - } + } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs index 078f7d7..b9835de 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel; using AppKit; using CoreGraphics; @@ -19,9 +19,9 @@ namespace Xamarin.PropertyEditing.Mac bool inhibitSelection; public override void OnViewModelChanged (BrushPropertyViewModel oldModel) - { + { inhibitSelection = true; - base.OnViewModelChanged(oldModel); + base.OnViewModelChanged (oldModel); foreach (var item in TabViewItems) { RemoveTabViewItem (item); @@ -34,7 +34,7 @@ namespace Xamarin.PropertyEditing.Mac foreach (var key in ViewModel.BrushTypes.Keys) { var item = new NSTabViewItem (); item.Label = key; - var brushType = ViewModel.BrushTypes[key]; + var brushType = ViewModel.BrushTypes [key]; switch (brushType) { case CommonBrushType.Solid: @@ -65,7 +65,7 @@ namespace Xamarin.PropertyEditing.Mac } if (item.ViewController != null) { - BrushTypeTable[brushType] = TabViewItems.Length; + BrushTypeTable [brushType] = TabViewItems.Length; AddTabViewItem (item); } } @@ -74,7 +74,7 @@ namespace Xamarin.PropertyEditing.Mac SelectedTabViewItemIndex = index; } inhibitSelection = false; - } + } public override void OnPropertyChanged (object sender, PropertyChangedEventArgs args) { @@ -88,8 +88,8 @@ namespace Xamarin.PropertyEditing.Mac } } - public override void WillSelect(NSTabView tabView, NSTabViewItem item) - { + public override void WillSelect (NSTabView tabView, NSTabViewItem item) + { var brushController = item.ViewController as PropertyViewController<BrushPropertyViewModel>; if (brushController != null) brushController.ViewModel = ViewModel; @@ -97,31 +97,31 @@ namespace Xamarin.PropertyEditing.Mac if (inhibitSelection) return; - base.WillSelect(tabView, item); - } + base.WillSelect (tabView, item); + } - public override void DidSelect(NSTabView tabView, NSTabViewItem item) - { + public override void DidSelect (NSTabView tabView, NSTabViewItem item) + { if (inhibitSelection) return; base.DidSelect (tabView, item); - ViewModel.SelectedBrushType = ViewModel.BrushTypes[item.Label]; - } + ViewModel.SelectedBrushType = ViewModel.BrushTypes [item.Label]; + } - public override void ViewDidLoad() - { + public override void ViewDidLoad () + { var old = View.Frame; old.Height = 230; View.Frame = old; inhibitSelection = true; - base.ViewDidLoad(); + base.ViewDidLoad (); inhibitSelection = false; old = View.Frame; //old.Height = 230; View.Frame = old; - } - } + } + } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ChannelEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ChannelEditor.cs index a3aad7e..8a09f44 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ChannelEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ChannelEditor.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using CoreAnimation; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs index aa4fb93..49f255f 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel; using System.Linq; using AppKit; @@ -32,7 +32,7 @@ namespace Xamarin.PropertyEditing.Mac Initialize (); } - ChannelGroup[] Editors { get; set; } + ChannelGroup [] Editors { get; set; } UnfocusableTextField hexLabel; NSTextField hexEditor; @@ -54,7 +54,7 @@ namespace Xamarin.PropertyEditing.Mac Gradient = new CAGradientLayer { StartPoint = new CGPoint (0, 0), EndPoint = new CGPoint (1, 0), - BorderWidth = .5f, + BorderWidth = .5f, } }; @@ -69,26 +69,26 @@ namespace Xamarin.PropertyEditing.Mac return ce; } - ChannelGroup[] CreateEditors (ChannelEditorType type) + ChannelGroup [] CreateEditors (ChannelEditorType type) { switch (type) { case ChannelEditorType.HSB: - return new[] { + return new [] { CreateEditor (new HsbHueChannelEditor ()), CreateEditor (new HsbSaturationChannelEditor ()), CreateEditor (new HsbBrightnessChannelEditor ()), CreateEditor (new AlphaChannelEditor ()) }; case ChannelEditorType.HLS: - return new[] { + return new [] { CreateEditor (new HlsHueChannelEditor ()), CreateEditor (new HlsLightnessChannelEditor ()), CreateEditor (new HlsSaturationChannelEditor ()), CreateEditor (new AlphaChannelEditor ()) }; case ChannelEditorType.RGB: - return new[] { + return new [] { CreateEditor (new RedChannelEditor ()), CreateEditor (new GreenChannelEditor ()), CreateEditor (new BlueChannelEditor ()), @@ -96,7 +96,7 @@ namespace Xamarin.PropertyEditing.Mac }; default: case ChannelEditorType.CMYK: - return new[] { + return new [] { CreateEditor (new CyanChannelEditor ()), CreateEditor (new MagentaChannelEditor ()), CreateEditor (new YellowChannelEditor ()), @@ -159,12 +159,12 @@ namespace Xamarin.PropertyEditing.Mac } } - public override void UpdateConstraints() - { - base.UpdateConstraints(); - } + public override void UpdateConstraints () + { + base.UpdateConstraints (); + } - ChannelGroup activeChannel; + ChannelGroup activeChannel; public override void MouseDown (NSEvent theEvent) { if (!ClickableGradients) { @@ -187,13 +187,13 @@ namespace Xamarin.PropertyEditing.Mac ViewModel.Color = channel.UpdateColorFromLocation ( grad, ViewModel.Color, - Layer.ConvertPointToLayer (location,grad.SuperLayer)); + Layer.ConvertPointToLayer (location, grad.SuperLayer)); return; } } } base.MouseDown (theEvent); - } + } public override void MouseDragged (NSEvent theEvent) { @@ -212,16 +212,16 @@ namespace Xamarin.PropertyEditing.Mac base.MouseMoved (theEvent); } - public override void MouseUp(NSEvent theEvent) - { + public override void MouseUp (NSEvent theEvent) + { if (activeChannel != null) ViewModel.CommitLastColor (); - + activeChannel = null; - base.MouseUp(theEvent); - } + base.MouseUp (theEvent); + } - public override void Layout () + public override void Layout () { base.Layout (); @@ -237,7 +237,7 @@ namespace Xamarin.PropertyEditing.Mac editorFrame.X, editorFrame.Y - DefaultGradientHeight + 1, editorFrame.Width - 16, DefaultGradientHeight); - + channelGroup.Gradient.BorderColor = NSColor.DisabledControlText.CGColor; channelGroup.Gradient.ContentsScale = Window?.Screen?.BackingScaleFactor ?? NSScreen.MainScreen.BackingScaleFactor; labelFrame = labelFrame.Translate (0, -yOffset); @@ -247,7 +247,7 @@ namespace Xamarin.PropertyEditing.Mac hexLabel.Frame = new CGRect (frame.X, padding, 20, DefaultControlHeight); hexEditor.Frame = new CGRect ( labelFrame.Right, - padding, + padding, frame.Width - labelFrame.Right - 16, DefaultControlHeight); } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentTabVewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentTabVewController.cs index 4d9df92..70fae75 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentTabVewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentTabVewController.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel; using AppKit; using Xamarin.PropertyEditing.ViewModels; @@ -7,8 +7,6 @@ namespace Xamarin.PropertyEditing.Mac { class ColorComponentTabViewController : PropertyTabViewController<SolidBrushViewModel> { - public ChannelEditorType EditorType { get; set; } - public ColorComponentTabViewController () { foreach (var value in Enum.GetValues (typeof (ChannelEditorType))) { @@ -20,14 +18,16 @@ namespace Xamarin.PropertyEditing.Mac } } - public override void OnViewModelChanged(SolidBrushViewModel oldModel) - { - base.OnViewModelChanged(oldModel); - var controller = TabView.Item(SelectedTabViewItemIndex).ViewController as ColorComponentViewController; + public ChannelEditorType EditorType { get; set; } + + public override void OnViewModelChanged (SolidBrushViewModel oldModel) + { + base.OnViewModelChanged (oldModel); + var controller = TabView.Item (SelectedTabViewItemIndex).ViewController as ColorComponentViewController; controller.ViewModel = ViewModel; - } + } - public override void WillSelect (NSTabView tabView, NSTabViewItem item) + public override void WillSelect (NSTabView tabView, NSTabViewItem item) { var controller = item.ViewController as ColorComponentViewController; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorLayer.cs index 1ec1025..bd5229d 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorLayer.cs @@ -1,4 +1,4 @@ -using System; +using System; using CoreAnimation; using CoreGraphics; using Foundation; @@ -11,12 +11,12 @@ namespace Xamarin.PropertyEditing.Mac { } - public override NSObject ActionForKey(string eventKey) - { + public override NSObject ActionForKey (string eventKey) + { return null; - } + } - public ColorEditorLayer (IntPtr handle) : base (handle) + public ColorEditorLayer (IntPtr handle) : base (handle) { } @@ -25,12 +25,13 @@ namespace Xamarin.PropertyEditing.Mac abstract public void UpdateFromLocation (EditorInteraction interaction, CGPoint location); } - class CAGradientLayerQuick : CAGradientLayer { - public CAGradientLayerQuick () + class UnanimatedGradientLayer : CAGradientLayer + { + public UnanimatedGradientLayer () { } - public CAGradientLayerQuick (IntPtr handle) : base (handle) + public UnanimatedGradientLayer (IntPtr handle) : base (handle) { } @@ -40,12 +41,13 @@ namespace Xamarin.PropertyEditing.Mac } } - class CALayerQuick : CALayer { - public CALayerQuick () + class UnanimatedLayer : CALayer + { + public UnanimatedLayer () { } - public CALayerQuick (IntPtr handle) : base (handle) + public UnanimatedLayer (IntPtr handle) : base (handle) { } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorView.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorView.cs index 82b57f1..7c7e4c1 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorView.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorView.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel; using AppKit; using CoreGraphics; @@ -33,8 +33,7 @@ namespace Xamarin.PropertyEditing.Mac adaptor = new NotifyingViewAdaptor<SolidBrushViewModel> (this); } - public SolidBrushViewModel ViewModel - { + public SolidBrushViewModel ViewModel { get => adaptor.ViewModel; set => adaptor.ViewModel = value; } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushLayer.cs index e49e560..6f04bb7 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushLayer.cs @@ -1,4 +1,4 @@ -using System; +using System; using AppKit; using CoreAnimation; using CoreGraphics; @@ -17,11 +17,9 @@ namespace Xamarin.PropertyEditing.Mac } CALayer brushLayer; - CALayer BrushLayer - { + CALayer BrushLayer { get => brushLayer; - set - { + set { if (brushLayer != null) brushLayer.RemoveFromSuperLayer (); @@ -33,11 +31,9 @@ namespace Xamarin.PropertyEditing.Mac } CommonBrush brush; - public CommonBrush Brush - { + public CommonBrush Brush { get => brush; - set - { + set { brush = value; BrushLayer = CreateBrushLayer (brush); Opacity = brush == null ? 0 : 1; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonGradientBrushLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonGradientBrushLayer.cs index 53a8885..c0644f9 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonGradientBrushLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonGradientBrushLayer.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using CoreAnimation; using CoreGraphics; @@ -17,11 +17,9 @@ namespace Xamarin.PropertyEditing.Mac } CommonGradientBrush brush; - public CommonGradientBrush Brush - { + public CommonGradientBrush Brush { get => brush; - set - { + set { brush = value; SetNeedsDisplay (); } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/DrawingExtensions.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/DrawingExtensions.cs index 57e0d73..e3d57a5 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/DrawingExtensions.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/DrawingExtensions.cs @@ -1,4 +1,4 @@ -using System; +using System; using AppKit; using CoreGraphics; using CoreImage; @@ -17,7 +17,7 @@ namespace Xamarin.PropertyEditing.Mac } public static NSImage CreateSwatch (this CommonColor color, CGSize size, CIColor c0, CIColor c1) - => new NSImage (GenerateCheckerboard (new CGRect (0, 0, size.Width,size.Height), c0, c1), size); + => new NSImage (GenerateCheckerboard (new CGRect (0, 0, size.Width, size.Height), c0, c1), size); public static CGImage GenerateCheckerboard (CGRect frame) @@ -29,7 +29,7 @@ namespace Xamarin.PropertyEditing.Mac Color0 = c0, Color1 = c1, Width = (float)Math.Min (frame.Height / 2f, 10), - Center = new CIVector (new nfloat[] { 0, 0 }), + Center = new CIVector (new nfloat [] { 0, 0 }), }) { using (var context = new CIContext (null)) { return context.CreateCGImage (board.OutputImage, new CGRect (0, 0, frame.Width, frame.Height)); @@ -64,7 +64,7 @@ namespace Xamarin.PropertyEditing.Mac public static CGRect Translate (this CGRect rect, double x, double y) => new CGRect ( - x: rect.X + x, + x: rect.X + x, y: rect.Y + y, width: rect.Width, height: rect.Height); diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/EmptyBrushEditorViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/EmptyBrushEditorViewController.cs index ca91629..bf68e53 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/EmptyBrushEditorViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/EmptyBrushEditorViewController.cs @@ -1,4 +1,4 @@ -using AppKit; +using AppKit; using CoreGraphics; using Xamarin.PropertyEditing.Drawing; using Xamarin.PropertyEditing.ViewModels; @@ -7,13 +7,13 @@ namespace Xamarin.PropertyEditing.Mac { class EmptyBrushEditorViewController : PropertyViewController<BrushPropertyViewModel> { - NSButton brushEditor; - public EmptyBrushEditorViewController () { PreferredContentSize = new CGSize (100, 100); } + NSButton brushEditor; + public override void LoadView () { View = brushEditor = new NSButton { diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/HistoryLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/HistoryLayer.cs index 4b86b1d..f27fe42 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/HistoryLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/HistoryLayer.cs @@ -1,4 +1,4 @@ -using System; +using System; using CoreAnimation; using CoreGraphics; @@ -49,7 +49,7 @@ namespace Xamarin.PropertyEditing.Mac 0, Bounds.Height, Bounds.Height).Inset (Margin, Margin); - + clip.Frame = new CGRect ( 0, 0, @@ -79,8 +79,8 @@ namespace Xamarin.PropertyEditing.Mac interaction.Color = interaction.ViewModel.InitialColor; } - public override void Commit (EditorInteraction interaction) - { - } - } + public override void Commit (EditorInteraction interaction) + { + } + } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/HueLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/HueLayer.cs index b5e3cc4..7a1560e 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/HueLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/HueLayer.cs @@ -1,4 +1,4 @@ -using System; +using System; using AppKit; using CoreAnimation; using CoreGraphics; @@ -13,8 +13,7 @@ namespace Xamarin.PropertyEditing.Mac ChannelEditor hueEditor = new HsbHueChannelEditor (); - public CGColor GripColor - { + public CGColor GripColor { get => grip.BorderColor; set => grip.BorderColor = value; } @@ -55,7 +54,7 @@ namespace Xamarin.PropertyEditing.Mac LayoutIfNeeded (); var color = interaction.Color; - + var loc = hueEditor.LocationFromColor (colors, color); grip.Frame = new CGRect (1, loc.Y - grip.Frame.Height / 2f, grip.Frame.Width, grip.Frame.Height); } @@ -80,12 +79,12 @@ namespace Xamarin.PropertyEditing.Mac location); } - public override void Commit(EditorInteraction viewModel) - { + public override void Commit (EditorInteraction viewModel) + { viewModel.ViewModel.CommitLastColor (); - } + } - public override void LayoutSublayers () + public override void LayoutSublayers () { base.LayoutSublayers (); colors.Frame = Bounds.Inset (2, 2); diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs index d38220e..aeb6aaa 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs @@ -7,7 +7,7 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - class MaterialBrushEditorViewController : PropertyViewController <BrushPropertyViewModel> + class MaterialBrushEditorViewController : PropertyViewController<BrushPropertyViewModel> { public MaterialBrushEditorViewController () { diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialColorLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialColorLayer.cs index 52785de..4968a29 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialColorLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialColorLayer.cs @@ -1,4 +1,4 @@ -using CoreAnimation; +using CoreAnimation; using CoreGraphics; using Xamarin.PropertyEditing.Drawing; @@ -16,33 +16,27 @@ namespace Xamarin.PropertyEditing.Mac }; string text; - public string Text - { + public string Text { get => text; - set - { + set { text = value; SetNeedsLayout (); } } CommonColor backgroundColor; - public new CommonColor BackgroundColor - { + public new CommonColor BackgroundColor { get => backgroundColor; - set - { + set { backgroundColor = value; base.BackgroundColor = backgroundColor.ToCGColor (); } } bool isSelected; - public bool IsSelected - { + public bool IsSelected { get => isSelected; - set - { + set { if (isSelected == value) return; isSelected = value; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs index 785d790..f8232c4 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs @@ -8,11 +8,11 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - class MaterialView : NSView + class MaterialView : NSView { public override bool IsFlipped => true; - static readonly string[] ColorNames = { + static readonly string [] ColorNames = { "50", "100", "200", @@ -25,14 +25,14 @@ namespace Xamarin.PropertyEditing.Mac "900" }; - static readonly string[] AccentNames = { + static readonly string [] AccentNames = { "A100", "A200", "A400", "A700" }; - static readonly string[] BlackWhite = { + static readonly string [] BlackWhite = { "White", "Black" }; @@ -48,21 +48,18 @@ namespace Xamarin.PropertyEditing.Mac } BrushPropertyViewModel viewModel; - public BrushPropertyViewModel ViewModel - { + public BrushPropertyViewModel ViewModel { get => viewModel; - set - { + set { if (viewModel == value) return; - + viewModel = value; NeedsLayout = true; } } - public MaterialDesignColorViewModel MaterialDesign - { + public MaterialDesignColorViewModel MaterialDesign { get => ViewModel?.MaterialDesign; } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/NotifyingViewAdaptor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/NotifyingViewAdaptor.cs index 75a9bea..2a64af3 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/NotifyingViewAdaptor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/NotifyingViewAdaptor.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel; namespace Xamarin.PropertyEditing.Mac @@ -19,11 +19,9 @@ namespace Xamarin.PropertyEditing.Mac INotifyingListner<T> listener; T viewModel; - internal T ViewModel - { + internal T ViewModel { get => viewModel; - set - { + set { var oldModel = viewModel; if (viewModel == value) return; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyTabViewController.cs index 0884588..f975dda 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyTabViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyTabViewController.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel; using AppKit; using Xamarin.PropertyEditing.ViewModels; @@ -12,7 +12,7 @@ namespace Xamarin.PropertyEditing.Mac adaptor = new NotifyingViewAdaptor<T> (this); } - protected NotifyingViewAdaptor<T> adaptor { get; } + protected NotifyingViewAdaptor<T> adaptor { get; } public virtual void OnPropertyChanged (object sender, PropertyChangedEventArgs args) { @@ -22,8 +22,7 @@ namespace Xamarin.PropertyEditing.Mac { } - internal T ViewModel - { + internal T ViewModel { get => adaptor.ViewModel; set => adaptor.ViewModel = value; } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyViewController.cs index ebf4d1f..ddb9531 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyViewController.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; @@ -12,8 +12,7 @@ namespace Xamarin.PropertyEditing.Mac { class PropertyViewController<T> : NSViewController, INotifyingListner<T> where T : NotifyingObject { - internal T ViewModel - { + internal T ViewModel { get => adaptor.ViewModel; set => adaptor.ViewModel = value; } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs index 7a42081..7b32594 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using AppKit; @@ -19,11 +19,11 @@ namespace Xamarin.PropertyEditing.Mac public override nint GetChildrenCount (NSOutlineView outlineView, NSObject item) { if (this.vm?.Resources == null) - return 0; - + return 0; + if (this.vm.Resources?.Count () == 0) return 0; - + return this.vm.Resources.Count (); } @@ -31,7 +31,7 @@ namespace Xamarin.PropertyEditing.Mac { object element; - element = (this.vm.Resources.ElementAt((int)childIndex)); + element = (this.vm.Resources.ElementAt ((int)childIndex)); return GetFacade (element); } @@ -46,7 +46,7 @@ namespace Xamarin.PropertyEditing.Mac NSObject facade; if (!this.groupFacades.TryGetValue (element, out facade)) { - this.groupFacades[element] = facade = new NSObjectFacade (element); + this.groupFacades [element] = facade = new NSObjectFacade (element); } return facade; } @@ -60,7 +60,8 @@ namespace Xamarin.PropertyEditing.Mac private readonly Dictionary<object, NSObject> groupFacades = new Dictionary<object, NSObject> (); } - class ResourceBrushPropertyViewDelegate : ResourceOutlineViewDelegate { + class ResourceBrushPropertyViewDelegate :ResourceOutlineViewDelegate + { public BrushPropertyViewModel ViewModel { get; set; @@ -78,7 +79,8 @@ namespace Xamarin.PropertyEditing.Mac } } - class ResourceOutlineViewDelegate : NSOutlineViewDelegate { + class ResourceOutlineViewDelegate :NSOutlineViewDelegate + { public override NSView GetView (NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { var facade = item as NSObjectFacade; @@ -113,7 +115,7 @@ namespace Xamarin.PropertyEditing.Mac } } - class ResourceOutlineView : NSOutlineView + class ResourceOutlineView :NSOutlineView { public ResourceOutlineView () { @@ -144,18 +146,16 @@ namespace Xamarin.PropertyEditing.Mac } ResourceSelectorViewModel viewModel; - public ResourceSelectorViewModel ViewModel - { + public ResourceSelectorViewModel ViewModel { get => viewModel; - set - { + set { viewModel = value; DataSource = new ResourceDataSource (viewModel); } } } - class ResourceBrushViewController : PropertyViewController<BrushPropertyViewModel> + class ResourceBrushViewController :PropertyViewController<BrushPropertyViewModel> { ResourceOutlineView resourceSelector; ResourceBrushPropertyViewDelegate viewDelegate; @@ -172,7 +172,7 @@ namespace Xamarin.PropertyEditing.Mac case nameof (BrushPropertyViewModel.Resource): if (resource == ViewModel.Resource) return; - + resource = ViewModel?.Resource; UpdateSelection (); break; @@ -189,11 +189,11 @@ namespace Xamarin.PropertyEditing.Mac { if (resourceSelector == null) return; - + var source = resourceSelector.DataSource as ResourceDataSource; if (source == null || ViewModel == null) return; - + nint index = -1; if (ViewModel.Resource != null && source.TryGetFacade (ViewModel?.Resource, out var facade)) { index = resourceSelector.RowForItem (facade); @@ -230,5 +230,5 @@ namespace Xamarin.PropertyEditing.Mac resourceSelector.ViewModel = ViewModel?.ResourceSelector; } } - } + } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ShadeLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ShadeLayer.cs index d03f758..de510a0 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ShadeLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ShadeLayer.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using AppKit; using CoreAnimation; @@ -45,7 +45,7 @@ namespace Xamarin.PropertyEditing.Mac }; readonly CAGradientLayer brightnessLayer = new CAGradientLayerQuick { - Colors = new[] { + Colors = new [] { new CGColor (0f, 0f, 0f, 1f), new CGColor (0f, 0f, 0f, 0f) }, @@ -53,7 +53,7 @@ namespace Xamarin.PropertyEditing.Mac }; readonly CAGradientLayer saturationLayer = new CAGradientLayerQuick { - Colors = new[] { + Colors = new [] { new CGColor (1f, 1f, 1f), new CGColor (1f, .3f, 0f) }, @@ -109,9 +109,9 @@ namespace Xamarin.PropertyEditing.Mac //interaction.Shade = shade; } - public override void Commit(EditorInteraction interaction) - { + public override void Commit (EditorInteraction interaction) + { interaction.ViewModel.CommitLastColor (); - } - } + } + } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs index 80edff2..67b1896 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel; using System.Linq; using System.Runtime.CompilerServices; @@ -37,9 +37,9 @@ namespace Xamarin.PropertyEditing.Mac } } - class SolidColorBrushEditor : ColorEditorView + class SolidColorBrushEditor :ColorEditorView { - public SolidColorBrushEditor (IntPtr handle) : base (handle) + public SolidColorBrushEditor (IntPtr handle) : base (handle) { Initialize (); } @@ -57,7 +57,7 @@ namespace Xamarin.PropertyEditing.Mac public SolidColorBrushEditor () : base () { - Initialize (); + Initialize (); } void Initialize () @@ -76,8 +76,8 @@ namespace Xamarin.PropertyEditing.Mac EditorType = ChannelEditorType.RGB }; - public override bool AcceptsFirstResponder() => true; - + public override bool AcceptsFirstResponder () => true; + readonly ShadeLayer shadeLayer = new ShadeLayer (); readonly HueLayer hueLayer = new HueLayer (); readonly HistoryLayer historyLayer = new HistoryLayer (); @@ -120,8 +120,8 @@ namespace Xamarin.PropertyEditing.Mac } CGPoint last; - public override void MouseDragged(NSEvent theEvent) - { + public override void MouseDragged (NSEvent theEvent) + { var location = ConvertPointFromView (theEvent.LocationInWindow, null); var diff = new CGPoint (last.X - location.X, last.Y - location.Y); @@ -133,14 +133,14 @@ namespace Xamarin.PropertyEditing.Mac Layer.ConvertPointToLayer (location, interaction.Layer)); OnPropertyChanged (ViewModel, new PropertyChangedEventArgs (nameof (SolidBrushViewModel.Color))); - } + } - public override void MouseUp(NSEvent theEvent) - { - base.MouseUp(theEvent); + public override void MouseUp (NSEvent theEvent) + { + base.MouseUp (theEvent); interaction?.Commit (); interaction = null; - } + } bool modelChanged = true; protected override void OnPropertyChanged (object sender, PropertyChangedEventArgs e) @@ -156,8 +156,8 @@ namespace Xamarin.PropertyEditing.Mac } protected override void OnViewModelChanged (SolidBrushViewModel oldModel) - { - base.OnViewModelChanged(oldModel); + { + base.OnViewModelChanged (oldModel); var inter = interaction ?? new EditorInteraction (ViewModel, null); componentTabs.ViewModel = ViewModel; @@ -166,7 +166,7 @@ namespace Xamarin.PropertyEditing.Mac } } - public override void Layout () + public override void Layout () { if (modelChanged) { var interx = interaction ?? new EditorInteraction (ViewModel, null); diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditorViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditorViewController.cs index 3c0cfa9..99d2677 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditorViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditorViewController.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.ComponentModel; using CoreGraphics; using Xamarin.PropertyEditing.ViewModels; @@ -34,15 +34,15 @@ namespace Xamarin.PropertyEditing.Mac brushEditor.ViewModel = ViewModel?.Solid; } - public override void ViewDidLoad() - { - base.ViewDidLoad(); + public override void ViewDidLoad () + { + base.ViewDidLoad (); if (ViewModel != null) brushEditor.ViewModel = ViewModel?.Solid; - } + } - public override void LoadView () + public override void LoadView () { View = brushEditor = new SolidColorBrushEditor { ViewModel = ViewModel?.Solid |