diff options
author | Larry Ewing <lewing@microsoft.com> | 2018-07-11 02:46:19 +0300 |
---|---|---|
committer | Larry Ewing <lewing@microsoft.com> | 2018-07-16 22:05:49 +0300 |
commit | 4d9e18e9230f4fd65ea97a700d6abcd7b15208a5 (patch) | |
tree | aac6bf61263c655576d057c67c3ff3a66b805dc7 /Xamarin.PropertyEditing.Mac | |
parent | 0a609e6fc80f77ca1bf5a12a5c8278eea93782b5 (diff) |
Style cleanups
Diffstat (limited to 'Xamarin.PropertyEditing.Mac')
29 files changed, 281 insertions, 266 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/AutoClosePopOver.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/AutoClosePopOver.cs index 2c2355f..7626277 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/AutoClosePopOver.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/AutoClosePopOver.cs @@ -3,7 +3,7 @@ using AppKit; namespace Xamarin.PropertyEditing.Mac { - public class AutoClosePopOver : NSPopover + internal class AutoClosePopOver : NSPopover { public AutoClosePopOver () : base () { diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs index 203a11f..24e12ca 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs @@ -30,7 +30,7 @@ namespace Xamarin.PropertyEditing.Mac var viewTitle = new UnfocusableTextField () { StringValue = title, TranslatesAutoresizingMaskIntoConstraints = false, - Font = NSFont.BoldSystemFontOfSize(11) + Font = NSFont.BoldSystemFontOfSize (11) }; AddSubview (viewTitle); @@ -47,7 +47,7 @@ namespace Xamarin.PropertyEditing.Mac viewTitle.ConstraintTo (this, (vt, c) => vt.Height == 24), }); - this.Appearance = PropertyEditorPanel.ThemeManager.CurrentAppearance; + Appearance = PropertyEditorPanel.ThemeManager.CurrentAppearance; } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverViewModelControl.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverViewModelControl.cs index 8cb139d..85352f5 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverViewModelControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverViewModelControl.cs @@ -14,7 +14,7 @@ namespace Xamarin.PropertyEditing.Mac if (viewModel == null) throw new ArgumentNullException (nameof (viewModel)); - this.ViewModel = viewModel; + ViewModel = viewModel; } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs index 7d4df21..93e2e50 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs @@ -8,7 +8,7 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - class BrushTabViewController : NotifyingTabViewController<BrushPropertyViewModel> + internal class BrushTabViewController : NotifyingTabViewController<BrushPropertyViewModel> { public BrushTabViewController () { @@ -21,7 +21,7 @@ namespace Xamarin.PropertyEditing.Mac public override void OnViewModelChanged (BrushPropertyViewModel oldModel) { - inhibitSelection = true; + this.inhibitSelection = true; base.OnViewModelChanged (oldModel); foreach (var item in TabViewItems) { @@ -74,7 +74,7 @@ namespace Xamarin.PropertyEditing.Mac if (BrushTypeTable.TryGetValue (ViewModel.SelectedBrushType, out var index)) { SelectedTabViewItemIndex = index; } - inhibitSelection = false; + this.inhibitSelection = false; } public override void OnPropertyChanged (object sender, PropertyChangedEventArgs args) @@ -94,8 +94,8 @@ namespace Xamarin.PropertyEditing.Mac var brushController = item.ViewController as NotifyingViewController<BrushPropertyViewModel>; if (brushController != null) brushController.ViewModel = ViewModel; - - if (inhibitSelection) + + if (this.inhibitSelection) return; base.WillSelect (tabView, item); @@ -103,7 +103,7 @@ namespace Xamarin.PropertyEditing.Mac public override void DidSelect (NSTabView tabView, NSTabViewItem item) { - if (inhibitSelection) + if (this.inhibitSelection) return; base.DidSelect (tabView, item); @@ -116,9 +116,9 @@ namespace Xamarin.PropertyEditing.Mac old.Height = 230; View.Frame = old; - inhibitSelection = true; + this.inhibitSelection = true; base.ViewDidLoad (); - inhibitSelection = false; + this.inhibitSelection = false; } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ChannelEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ChannelEditor.cs index 1991c90..839de0a 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ChannelEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ChannelEditor.cs @@ -7,7 +7,7 @@ using Xamarin.PropertyEditing.Drawing; namespace Xamarin.PropertyEditing.Mac { - public abstract class ChannelEditor + internal abstract class ChannelEditor { public string Name { get; } public double MinimumValue { get; } @@ -88,7 +88,7 @@ namespace Xamarin.PropertyEditing.Mac public abstract double ValueFromColor (CommonColor color); } - class RedChannelEditor : ChannelEditor + internal class RedChannelEditor : ChannelEditor { public RedChannelEditor () : base ("R", 0d, 255d, 1d) { @@ -101,7 +101,7 @@ namespace Xamarin.PropertyEditing.Mac => color.UpdateRGB (r: (byte)Clamp (value)); } - class GreenChannelEditor : ChannelEditor + internal class GreenChannelEditor : ChannelEditor { public GreenChannelEditor () : base ("G", 0d, 255d, 1d) { @@ -114,7 +114,7 @@ namespace Xamarin.PropertyEditing.Mac => color.UpdateRGB (g: (byte)Clamp (value)); } - class BlueChannelEditor : ChannelEditor + internal class BlueChannelEditor : ChannelEditor { public BlueChannelEditor () : base ("B", 0d, 255d, 1d) { @@ -127,7 +127,7 @@ namespace Xamarin.PropertyEditing.Mac => color.UpdateRGB (b: (byte)Clamp (value)); } - class AlphaChannelEditor : ChannelEditor + internal class AlphaChannelEditor : ChannelEditor { public AlphaChannelEditor () : base ("A", 0d, 255d, 1d) { @@ -140,7 +140,7 @@ namespace Xamarin.PropertyEditing.Mac => color.UpdateRGB (a: (byte)Clamp (value)); } - class CyanChannelEditor : ChannelEditor + internal class CyanChannelEditor : ChannelEditor { public CyanChannelEditor () : base ("C", 0d, 1d, .001d) { @@ -153,7 +153,7 @@ namespace Xamarin.PropertyEditing.Mac => color.UpdateCMYK (c: Clamp (value)); } - class MagentaChannelEditor : ChannelEditor + internal class MagentaChannelEditor : ChannelEditor { public MagentaChannelEditor () : base ("M", 0d, 1d, .001d) { @@ -166,7 +166,7 @@ namespace Xamarin.PropertyEditing.Mac => color.UpdateCMYK (m: Clamp (value)); } - class YellowChannelEditor : ChannelEditor + internal class YellowChannelEditor : ChannelEditor { public YellowChannelEditor () : base ("Y", 0d, 1d, .001d) { @@ -179,7 +179,7 @@ namespace Xamarin.PropertyEditing.Mac => color.UpdateCMYK (y: Clamp (value)); } - class BlackChannelEditor : ChannelEditor + internal class BlackChannelEditor : ChannelEditor { public BlackChannelEditor () : base ("K", 0d, 1d, .001d) { @@ -192,7 +192,7 @@ namespace Xamarin.PropertyEditing.Mac => color.UpdateCMYK (k: Clamp (value)); } - class HsbHueChannelEditor : ChannelEditor + internal class HsbHueChannelEditor : ChannelEditor { public HsbHueChannelEditor () : base ("H", 0d, 360d, 1d) { @@ -205,7 +205,7 @@ namespace Xamarin.PropertyEditing.Mac => color.UpdateHSB (hue: Clamp (value)); } - class HsbSaturationChannelEditor : ChannelEditor + internal class HsbSaturationChannelEditor : ChannelEditor { public HsbSaturationChannelEditor () : base ("S", 0d, 1d, .001d) { @@ -218,7 +218,7 @@ namespace Xamarin.PropertyEditing.Mac => color.UpdateHSB (saturation: Clamp (value)); } - class HsbBrightnessChannelEditor : ChannelEditor + internal class HsbBrightnessChannelEditor : ChannelEditor { public HsbBrightnessChannelEditor () : base ("B", 0d, 1d, .001d) { @@ -231,7 +231,7 @@ namespace Xamarin.PropertyEditing.Mac => color.UpdateHSB (brightness: Clamp (value)); } - class HsbAlphaChannelEditor : ChannelEditor + internal class HsbAlphaChannelEditor : ChannelEditor { public HsbAlphaChannelEditor () : base ("A", 0d, 255d, 1d) { @@ -244,7 +244,7 @@ namespace Xamarin.PropertyEditing.Mac => color.UpdateHSB (alpha: (byte)Clamp (value)); } - class HlsHueChannelEditor : ChannelEditor + internal class HlsHueChannelEditor : ChannelEditor { public HlsHueChannelEditor () : base ("H", 0d, 360d, 1d) { @@ -257,7 +257,7 @@ namespace Xamarin.PropertyEditing.Mac => color.UpdateHLS (hue: Clamp (value)); } - class HlsLightnessChannelEditor : ChannelEditor + internal class HlsLightnessChannelEditor : ChannelEditor { public HlsLightnessChannelEditor () : base ("L", 0d, 1d, .001d) { @@ -270,7 +270,7 @@ namespace Xamarin.PropertyEditing.Mac => color.UpdateHLS (lightness: Clamp (value)); } - class HlsSaturationChannelEditor : ChannelEditor + internal class HlsSaturationChannelEditor : ChannelEditor { public HlsSaturationChannelEditor () : base ("S", 0d, 1d, .001d) { @@ -283,7 +283,7 @@ namespace Xamarin.PropertyEditing.Mac => color.UpdateHLS (saturation: Clamp (value)); } - class HlsAlphaChannelEditor : ChannelEditor + internal class HlsAlphaChannelEditor : ChannelEditor { public HlsAlphaChannelEditor () : base ("A", 0d, 255d, 1d) { diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ChannelEditorType.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ChannelEditorType.cs index c9747fe..9478d67 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ChannelEditorType.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ChannelEditorType.cs @@ -1,6 +1,6 @@ namespace Xamarin.PropertyEditing.Mac { - public enum ChannelEditorType + internal enum ChannelEditorType { RGB, HLS, diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs index fea962a..900635f 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs @@ -9,14 +9,14 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - class ColorComponentEditor : ColorEditorView + internal class ColorComponentEditor : ColorEditorView { - const int DefaultPropertyButtonSize = 10; - const int DefaultActioButtonSize = 16; - const int DefaultControlHeight = 22; - const int DefaultGradientHeight = 4; + private const int DefaultPropertyButtonSize = 10; + private const int DefaultActioButtonSize = 16; + private const int DefaultControlHeight = 22; + private const int DefaultGradientHeight = 4; - ChannelEditorType EditorType { get; } + private ChannelEditorType EditorType { get; } public bool ClickableGradients { get; set; } = true; @@ -32,9 +32,9 @@ namespace Xamarin.PropertyEditing.Mac Initialize (); } - ChannelGroup [] Editors { get; set; } - UnfocusableTextField hexLabel; - NSTextField hexEditor; + private ChannelGroup [] Editors { get; set; } + private UnfocusableTextField hexLabel; + private NSTextField hexEditor; class ChannelGroup { @@ -43,7 +43,7 @@ namespace Xamarin.PropertyEditing.Mac public CAGradientLayer Gradient { get; set; } } - ChannelGroup CreateEditor (ChannelEditor editor) + private ChannelGroup CreateEditor (ChannelEditor editor) { var ce = new ChannelGroup { Label = new UnfocusableTextField { @@ -70,9 +70,8 @@ namespace Xamarin.PropertyEditing.Mac return ce; } - ChannelGroup [] CreateEditors (ChannelEditorType type) + private ChannelGroup [] CreateEditors (ChannelEditorType type) { - switch (type) { case ChannelEditorType.HSB: return new [] { @@ -107,28 +106,28 @@ namespace Xamarin.PropertyEditing.Mac } } - void Initialize () + private void Initialize () { WantsLayer = true; Editors = CreateEditors (EditorType); - hexLabel = new UnfocusableTextField { + this.hexLabel = new UnfocusableTextField { StringValue = "#:", Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.Clear }; - AddSubview (hexLabel); + AddSubview (this.hexLabel); - hexEditor = new NSTextField { + this.hexEditor = new NSTextField { Alignment = NSTextAlignment.Right, BackgroundColor = NSColor.Clear }; - AddSubview (hexEditor); + AddSubview (this.hexEditor); - hexEditor.EditingEnded += (o, e) => { - if (CommonColor.TryParseArgbHex (hexEditor.StringValue, out CommonColor c)) { + this.hexEditor.EditingEnded += (o, e) => { + if (CommonColor.TryParseArgbHex (this.hexEditor.StringValue, out CommonColor c)) { ViewModel.Color = c; - hexEditor.StringValue = c.ToString (); + this.hexEditor.StringValue = c.ToString (); } }; } @@ -146,7 +145,7 @@ namespace Xamarin.PropertyEditing.Mac ViewModel.CommitLastColor (); } - protected override void OnPropertyChanged (object sender, PropertyChangedEventArgs e) + public override void OnPropertyChanged (object sender, PropertyChangedEventArgs e) { base.OnPropertyChanged (sender, e); @@ -160,7 +159,7 @@ namespace Xamarin.PropertyEditing.Mac editor.Value = editor.ComponentEditor.ValueFromColor (ViewModel.Color); editor.ComponentEditor.UpdateGradientLayer (channelGroup.Gradient, ViewModel.Color); } - hexEditor.StringValue = ViewModel.Color.ToString (); + this.hexEditor.StringValue = ViewModel.Color.ToString (); break; } } @@ -170,11 +169,11 @@ namespace Xamarin.PropertyEditing.Mac base.UpdateConstraints (); } - ChannelGroup activeChannel; + private ChannelGroup activeChannel; public override void MouseDown (NSEvent theEvent) { if (!ClickableGradients) { - activeChannel = null; + this.activeChannel = null; base.MouseDown (theEvent); return; } @@ -186,10 +185,10 @@ namespace Xamarin.PropertyEditing.Mac var hit = layer.PresentationLayer.HitTest (location) ?? layer.PresentationLayer.HitTest (new CGPoint (location.X, location.Y + 4)); for (var currentLayer = hit; currentLayer != null; currentLayer = currentLayer.SuperLayer) { - activeChannel = Editors.FirstOrDefault (ce => ce.Gradient == currentLayer.ModelLayer); - if (activeChannel != null) { - var channel = activeChannel.Editor.ComponentEditor; - var grad = activeChannel.Gradient; + this.activeChannel = Editors.FirstOrDefault (ce => ce.Gradient == currentLayer.ModelLayer); + if (this.activeChannel != null) { + var channel = this.activeChannel.Editor.ComponentEditor; + var grad = this.activeChannel.Gradient; ViewModel.Color = channel.UpdateColorFromLocation ( grad, ViewModel.Color, @@ -206,9 +205,9 @@ namespace Xamarin.PropertyEditing.Mac var location = ConvertPointFromView (theEvent.LocationInWindow, null); location = ConvertPointToLayer (location); - if (activeChannel != null) { - var channel = activeChannel.Editor.ComponentEditor; - var grad = activeChannel.Gradient; + if (this.activeChannel != null) { + var channel = this.activeChannel.Editor.ComponentEditor; + var grad = this.activeChannel.Gradient; ViewModel.Color = channel.UpdateColorFromLocation ( grad, ViewModel.Color, @@ -220,10 +219,10 @@ namespace Xamarin.PropertyEditing.Mac public override void MouseUp (NSEvent theEvent) { - if (activeChannel != null) + if (this.activeChannel != null) ViewModel.CommitLastColor (); - activeChannel = null; + this.activeChannel = null; base.MouseUp (theEvent); } @@ -250,8 +249,8 @@ namespace Xamarin.PropertyEditing.Mac editorFrame = editorFrame.Translate (0, -yOffset); } - hexLabel.Frame = new CGRect (frame.X, padding, 20, DefaultControlHeight); - hexEditor.Frame = new CGRect ( + this.hexLabel.Frame = new CGRect (frame.X, padding, 20, DefaultControlHeight); + this.hexEditor.Frame = new CGRect ( labelFrame.Right, padding, frame.Width - labelFrame.Right - 16, diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentTabViewController.cs index 2723c1d..0e51c03 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentTabViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentTabViewController.cs @@ -5,7 +5,7 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - class ColorComponentTabViewController : NotifyingTabViewController<SolidBrushViewModel> + internal class ColorComponentTabViewController : NotifyingTabViewController<SolidBrushViewModel> { public ColorComponentTabViewController () { @@ -35,14 +35,14 @@ namespace Xamarin.PropertyEditing.Mac base.WillSelect (tabView, item); controller.ViewModel = ViewModel; - this.EditorType = controller.EditorType; + EditorType = controller.EditorType; } public override void DidSelect (NSTabView tabView, NSTabViewItem item) { base.DidSelect (tabView, item); var controller = item.ViewController as ColorComponentViewController; - this.EditorType = controller.EditorType; + EditorType = controller.EditorType; } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs index 027c69a..9680752 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs @@ -6,14 +6,14 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - class ColorComponentViewController : NotifyingViewController<SolidBrushViewModel> + internal class ColorComponentViewController : NotifyingViewController<SolidBrushViewModel> { - ColorComponentEditor editor; + private ColorComponentEditor editor; public ColorComponentViewController (ChannelEditorType type) : base () { PreferredContentSize = new CGSize (200, 220); - this.EditorType = type; + EditorType = type; } public ChannelEditorType EditorType { get; } @@ -21,24 +21,24 @@ namespace Xamarin.PropertyEditing.Mac public override void OnViewModelChanged (SolidBrushViewModel oldModel) { base.OnViewModelChanged (oldModel); - editor.ViewModel = ViewModel; + this.editor.ViewModel = ViewModel; } public override void ViewWillDisappear () { base.ViewWillDisappear (); - editor.ViewModel = null; + this.editor.ViewModel = null; } public override void ViewWillAppear () { base.ViewWillAppear (); - editor.ViewModel = ViewModel; + this.editor.ViewModel = ViewModel; } public override void LoadView () { - View = editor = new ColorComponentEditor (this.EditorType); + View = this.editor = new ColorComponentEditor (this.EditorType); } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorLayer.cs index bd5229d..6657ba1 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorLayer.cs @@ -5,7 +5,7 @@ using Foundation; namespace Xamarin.PropertyEditing.Mac { - abstract class ColorEditorLayer : CALayer + abstract internal class ColorEditorLayer : CALayer { public ColorEditorLayer () { @@ -25,7 +25,7 @@ namespace Xamarin.PropertyEditing.Mac abstract public void UpdateFromLocation (EditorInteraction interaction, CGPoint location); } - class UnanimatedGradientLayer : CAGradientLayer + internal class UnanimatedGradientLayer : CAGradientLayer { public UnanimatedGradientLayer () { @@ -41,7 +41,7 @@ namespace Xamarin.PropertyEditing.Mac } } - class UnanimatedLayer : CALayer + internal class UnanimatedLayer : CALayer { public UnanimatedLayer () { diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorView.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorView.cs index 7c7e4c1..32a58fb 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorView.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorEditorView.cs @@ -7,46 +7,75 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - abstract class ColorEditorView : NSView, INotifyingListner<SolidBrushViewModel> + internal class NotifyingView<TViewModel> : NSView, INotifyingListner<TViewModel> where TViewModel : NotifyingObject + { + internal TViewModel ViewModel + { + get => Adaptor.ViewModel; + set => Adaptor.ViewModel = value; + } + + public NotifyingView () + { + Adaptor = new NotifyingViewAdaptor<TViewModel> (this); + } + + public NotifyingView (CGRect frame) : base (frame) + { + Adaptor = new NotifyingViewAdaptor<TViewModel> (this); + } + + public NotifyingView (IntPtr handle) : base (handle) + { + } + + [Export ("initWithCoder:")] + public NotifyingView (NSCoder coder) : base (coder) + { + } + + protected NotifyingViewAdaptor<TViewModel> Adaptor { get; } + + public virtual void OnViewModelChanged (TViewModel oldModel) + { + } + + public virtual void OnPropertyChanged (object sender, PropertyChangedEventArgs e) + { + } + } + + internal abstract class ColorEditorView : NotifyingView<SolidBrushViewModel> { protected const float padding = 3; - protected NotifyingViewAdaptor<SolidBrushViewModel> adaptor { get; } public ColorEditorView (IntPtr handle) : base (handle) { - adaptor = new NotifyingViewAdaptor<SolidBrushViewModel> (this); } - [Export ("initWithCoder:")] + public ColorEditorView (NSCoder coder) : base (coder) { - adaptor = new NotifyingViewAdaptor<SolidBrushViewModel> (this); } public ColorEditorView (CGRect frame) : base (frame) { - adaptor = new NotifyingViewAdaptor<SolidBrushViewModel> (this); } - public ColorEditorView () : base () + public ColorEditorView () { - adaptor = new NotifyingViewAdaptor<SolidBrushViewModel> (this); } - public SolidBrushViewModel ViewModel { - get => adaptor.ViewModel; - set => adaptor.ViewModel = value; + public new SolidBrushViewModel ViewModel { + get => Adaptor.ViewModel; + set => Adaptor.ViewModel = value; } - protected virtual void OnViewModelChanged (SolidBrushViewModel oldModel) + public override void OnViewModelChanged (SolidBrushViewModel oldModel) { OnPropertyChanged (ViewModel, new PropertyChangedEventArgs (nameof (SolidBrushViewModel.Color))); } - protected virtual void OnPropertyChanged (object sender, PropertyChangedEventArgs e) - { - } - public override void MouseDragged (NSEvent theEvent) { //base.MouseDragged (theEvent); @@ -70,17 +99,7 @@ namespace Xamarin.PropertyEditing.Mac if (!disposing) return; - adaptor.Disconnect (); - } - - void INotifyingListner<SolidBrushViewModel>.OnViewModelChanged (SolidBrushViewModel oldModel) - { - OnViewModelChanged (oldModel); - } - - void INotifyingListner<SolidBrushViewModel>.OnPropertyChanged (object sender, PropertyChangedEventArgs e) - { - OnPropertyChanged (sender, e); + Adaptor.Disconnect (); } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushLayer.cs index 6f04bb7..c12362c 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushLayer.cs @@ -6,7 +6,7 @@ using Xamarin.PropertyEditing.Drawing; namespace Xamarin.PropertyEditing.Mac { - class CommonBrushLayer : CALayer + internal class CommonBrushLayer : CALayer { public CommonBrushLayer () { @@ -16,8 +16,8 @@ namespace Xamarin.PropertyEditing.Mac MasksToBounds = true; } - CALayer brushLayer; - CALayer BrushLayer { + private CALayer brushLayer; + private CALayer BrushLayer { get => brushLayer; set { if (brushLayer != null) @@ -30,7 +30,7 @@ namespace Xamarin.PropertyEditing.Mac } } - CommonBrush brush; + private CommonBrush brush; public CommonBrush Brush { get => brush; set { diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushView.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushView.cs index f2affff..c9118de 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushView.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushView.cs @@ -5,7 +5,7 @@ using Xamarin.PropertyEditing.Drawing; namespace Xamarin.PropertyEditing.Mac { - public class CommonBrushView : NSView + internal class CommonBrushView : NSView { public CommonBrush Brush { get => (Layer as CommonBrushLayer)?.Brush; @@ -26,7 +26,7 @@ namespace Xamarin.PropertyEditing.Mac { } - void Initialize () { + private void Initialize () { WantsLayer = true; Layer = new CommonBrushLayer { diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonGradientBrushLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonGradientBrushLayer.cs index c0644f9..fe9200d 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonGradientBrushLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonGradientBrushLayer.cs @@ -6,7 +6,7 @@ using Xamarin.PropertyEditing.Drawing; namespace Xamarin.PropertyEditing.Mac { - class CommonGradientBrushLayer : CALayer + internal class CommonGradientBrushLayer : CALayer { public CommonGradientBrushLayer () { @@ -16,7 +16,7 @@ namespace Xamarin.PropertyEditing.Mac { } - CommonGradientBrush brush; + private CommonGradientBrush brush; public CommonGradientBrush Brush { get => brush; set { diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ComponentSpinEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ComponentSpinEditor.cs index a02973d..6be4c65 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ComponentSpinEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ComponentSpinEditor.cs @@ -1,6 +1,6 @@ namespace Xamarin.PropertyEditing.Mac { - class ComponentSpinEditor : NumericSpinEditor + internal class ComponentSpinEditor : NumericSpinEditor { public ComponentSpinEditor (ChannelEditor component) { diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/EmptyBrushEditorViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/EmptyBrushEditorViewController.cs index bbb3ad5..24273e1 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/EmptyBrushEditorViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/EmptyBrushEditorViewController.cs @@ -12,7 +12,7 @@ namespace Xamarin.PropertyEditing.Mac PreferredContentSize = new CGSize (100, 100); } - NSButton brushEditor; + private NSButton brushEditor; public override void LoadView () { diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/HistoryLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/HistoryLayer.cs index 725c8a4..84fcbcf 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/HistoryLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/HistoryLayer.cs @@ -4,10 +4,10 @@ using CoreGraphics; namespace Xamarin.PropertyEditing.Mac { - class HistoryLayer : ColorEditorLayer + internal class HistoryLayer : ColorEditorLayer { - const float Margin = 3; - const float BorderRadius = 3; + private const float Margin = 3; + private const float BorderRadius = 3; public HistoryLayer () { @@ -22,18 +22,18 @@ namespace Xamarin.PropertyEditing.Mac { } - readonly CALayer previous = new UnanimatedLayer (); - readonly CALayer current = new UnanimatedLayer (); - readonly CALayer last = new UnanimatedLayer (); + private readonly CALayer previous = new UnanimatedLayer (); + private readonly CALayer current = new UnanimatedLayer (); + private readonly CALayer last = new UnanimatedLayer (); - readonly CALayer lastClip = new CALayer { + private readonly CALayer lastClip = new UnanimatedLayer { BorderWidth = 1, CornerRadius = BorderRadius, BorderColor = new CGColor (.5f, .5f, .5f, .5f), MasksToBounds = true }; - readonly CALayer clip = new CALayer { + private readonly CALayer clip = new UnanimatedLayer { BorderWidth = 1, CornerRadius = BorderRadius, BorderColor = new CGColor (.5f, .5f, .5f, .5f), @@ -44,25 +44,25 @@ namespace Xamarin.PropertyEditing.Mac { base.LayoutSublayers (); - lastClip.Frame = new CGRect ( + this.lastClip.Frame = new CGRect ( Bounds.Right - Bounds.Height, 0, Bounds.Height, Bounds.Height).Inset (Margin, Margin); - clip.Frame = new CGRect ( + this.clip.Frame = new CGRect ( 0, 0, Bounds.Width - Bounds.Height + Margin, Bounds.Height).Inset (Margin, Margin); - clip.Contents = DrawingExtensions.GenerateCheckerboard (clip.Bounds); - lastClip.Contents = DrawingExtensions.GenerateCheckerboard (last.Bounds); - last.Frame = lastClip.Bounds; + this.clip.Contents = DrawingExtensions.GenerateCheckerboard (this.clip.Bounds); + this.lastClip.Contents = DrawingExtensions.GenerateCheckerboard (this.last.Bounds); + this.last.Frame = this.lastClip.Bounds; var width = clip.Frame.Width / 2; - previous.Frame = new CGRect (0, 0, width, clip.Frame.Height); - current.Frame = new CGRect (width, 0, width, clip.Frame.Height); + previous.Frame = new CGRect (0, 0, width, this.clip.Frame.Height); + current.Frame = new CGRect (width, 0, width, this.clip.Frame.Height); } public override void UpdateFromModel (EditorInteraction interaction) diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/HueLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/HueLayer.cs index 5a4c185..420e9ca 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/HueLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/HueLayer.cs @@ -8,10 +8,10 @@ namespace Xamarin.PropertyEditing.Mac { class HueLayer : ColorEditorLayer { - const float BorderRadius = 3; - const float GripRadius = 3; + private const float BorderRadius = 3; + private const float GripRadius = 3; - ChannelEditor hueEditor = new HsbHueChannelEditor (); + private readonly ChannelEditor hueEditor = new HsbHueChannelEditor (); public CGColor GripColor { get => grip.BorderColor; @@ -27,14 +27,14 @@ namespace Xamarin.PropertyEditing.Mac { } - void Initialize () + private void Initialize () { - hueEditor.UpdateGradientLayer (colors, new CommonColor (0, 255, 0)); + this.hueEditor.UpdateGradientLayer (this.colors, new CommonColor (0, 255, 0)); AddSublayer (colors); AddSublayer (grip); } - readonly CAGradientLayer colors = new CAGradientLayer { + private readonly CAGradientLayer colors = new CAGradientLayer { BorderColor = new CGColor (.5f, .5f, .5f, .5f), StartPoint = new CGPoint (0, 1), EndPoint = new CGPoint (0, 0), @@ -42,30 +42,29 @@ namespace Xamarin.PropertyEditing.Mac CornerRadius = BorderRadius, }; - readonly CALayer grip = new UnanimatedLayer { + private readonly CALayer grip = new UnanimatedLayer { BorderColor = NSColor.Text.CGColor, BorderWidth = 2, CornerRadius = GripRadius, }; - CommonColor c; public override void UpdateFromModel (EditorInteraction interaction) { 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); + var loc = this.hueEditor.LocationFromColor (this.colors, color); + this.grip.Frame = new CGRect (1, loc.Y - this.grip.Frame.Height / 2f, this.Frame.Width, this.grip.Frame.Height); } public override void UpdateFromLocation (EditorInteraction interaction, CGPoint location) { - var clos = Math.Min (colors.Frame.Height, Math.Max (0, location.Y - colors.Frame.Y)); + var clos = Math.Min (this.colors.Frame.Height, Math.Max (0, location.Y - this.colors.Frame.Y)); - grip.Frame = new CGRect ( + this.grip.Frame = new CGRect ( 1, - clos + colors.Frame.Y - grip.Frame.Height * 0.5f, + clos + this.colors.Frame.Y - this.grip.Frame.Height * 0.5f, Frame.Width - 2, 2 * GripRadius); @@ -73,24 +72,24 @@ namespace Xamarin.PropertyEditing.Mac return; var color = interaction.Color; - c = interaction.Color = hueEditor.UpdateColorFromLocation ( - colors, + interaction.Color = this.hueEditor.UpdateColorFromLocation ( + this.colors, color, location); } - public override void Commit (EditorInteraction viewModel) + public override void Commit (EditorInteraction interaction) { - viewModel.ViewModel.CommitLastColor (); + interaction.ViewModel.CommitLastColor (); } public override void LayoutSublayers () { base.LayoutSublayers (); - colors.Frame = Bounds.Inset (2, 2); - grip.Frame = new CGRect ( - grip.Frame.X, - grip.Frame.Y, + this.colors.Frame = Bounds.Inset (2, 2); + this.grip.Frame = new CGRect ( + this.grip.Frame.X, + this.grip.Frame.Y, Frame.Width - 2, 2 * GripRadius); } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs index 32fdbf3..933eeef 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs @@ -14,15 +14,15 @@ namespace Xamarin.PropertyEditing.Mac PreferredContentSize = new CGSize (200, 230); } - MaterialView materialEditor; + private MaterialView materialEditor; public override void OnPropertyChanged (object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case nameof (BrushPropertyViewModel.Value): case nameof (BrushPropertyViewModel.MaterialDesign): - if (materialEditor != null) - materialEditor.ViewModel = ViewModel; + if (this.materialEditor != null) + this.materialEditor.ViewModel = ViewModel; break; } } @@ -30,7 +30,7 @@ namespace Xamarin.PropertyEditing.Mac public override void OnViewModelChanged (BrushPropertyViewModel oldModel) { if (ViewLoaded && materialEditor != null) - materialEditor.ViewModel = ViewModel; + this.materialEditor.ViewModel = ViewModel; } public override void LoadView () diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialColorLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialColorLayer.cs index 4968a29..02ba820 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialColorLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialColorLayer.cs @@ -8,38 +8,38 @@ namespace Xamarin.PropertyEditing.Mac { public MaterialColorLayer () { - AddSublayer (selection); + AddSublayer (this.selection); } - readonly CATextLayer selection = new CATextLayer () { + private readonly CATextLayer selection = new CATextLayer () { CornerRadius = 3 }; - string text; + private string text; public string Text { - get => text; + get => this.text; set { - text = value; + this.text = value; SetNeedsLayout (); } } - CommonColor backgroundColor; + private CommonColor backgroundColor; public new CommonColor BackgroundColor { - get => backgroundColor; + get => this.backgroundColor; set { - backgroundColor = value; - base.BackgroundColor = backgroundColor.ToCGColor (); + this.backgroundColor = value; + base.BackgroundColor = this.backgroundColor.ToCGColor (); } } - bool isSelected; + private bool isSelected; public bool IsSelected { - get => isSelected; + get => this.isSelected; set { - if (isSelected == value) + if (this.isSelected == value) return; - isSelected = value; + this.isSelected = value; SetNeedsLayout (); } } @@ -48,14 +48,14 @@ namespace Xamarin.PropertyEditing.Mac { base.LayoutSublayers (); - selection.String = text; - selection.Frame = Bounds.Inset (3, 3); - selection.BorderWidth = isSelected ? 2 : 0; - selection.BorderColor = ForegroundColor; - selection.ForegroundColor = ForegroundColor; - selection.FontSize = FontSize; - selection.ContentsScale = ContentsScale; - selection.TextAlignmentMode = TextAlignmentMode; + this.selection.String = this.text; + this.selection.Frame = Bounds.Inset (3, 3); + this.selection.BorderWidth = this.isSelected ? 2 : 0; + this.selection.BorderColor = ForegroundColor; + this.selection.ForegroundColor = ForegroundColor; + this.selection.FontSize = FontSize; + this.selection.ContentsScale = ContentsScale; + this.selection.TextAlignmentMode = TextAlignmentMode; } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs index 1b79a9b..423b0d5 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs @@ -8,7 +8,7 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - class MaterialView : NSView + internal class MaterialView : NSView { public override bool IsFlipped => true; @@ -17,12 +17,12 @@ namespace Xamarin.PropertyEditing.Mac Initialize (); } - void Initialize () + private void Initialize () { WantsLayer = true; } - BrushPropertyViewModel viewModel; + private BrushPropertyViewModel viewModel; public BrushPropertyViewModel ViewModel { get => viewModel; set { diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/NotifyingTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/NotifyingTabViewController.cs index ede808c..95a7581 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/NotifyingTabViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/NotifyingTabViewController.cs @@ -9,10 +9,10 @@ namespace Xamarin.PropertyEditing.Mac { public NotifyingTabViewController () : base () { - adaptor = new NotifyingViewAdaptor<T> (this); + Adaptor = new NotifyingViewAdaptor<T> (this); } - protected NotifyingViewAdaptor<T> adaptor { get; } + protected NotifyingViewAdaptor<T> Adaptor { get; } public virtual void OnPropertyChanged (object sender, PropertyChangedEventArgs args) { @@ -23,8 +23,8 @@ namespace Xamarin.PropertyEditing.Mac } internal T ViewModel { - get => adaptor.ViewModel; - set => adaptor.ViewModel = value; + get => Adaptor.ViewModel; + set => Adaptor.ViewModel = value; } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/NotifyingViewAdaptor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/NotifyingViewAdaptor.cs index 0cda4ff..9a11060 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/NotifyingViewAdaptor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/NotifyingViewAdaptor.cs @@ -3,22 +3,22 @@ using System.ComponentModel; namespace Xamarin.PropertyEditing.Mac { - interface INotifyingListner<T> where T : NotifyingObject + internal interface INotifyingListner<T> where T : NotifyingObject { void OnViewModelChanged (T oldModel); void OnPropertyChanged (object sender, PropertyChangedEventArgs e); } - class NotifyingViewAdaptor<T> where T : NotifyingObject + internal class NotifyingViewAdaptor<T> where T : NotifyingObject { public NotifyingViewAdaptor (INotifyingListner<T> listener) { this.listener = listener; } - INotifyingListner<T> listener; + private INotifyingListner<T> listener; - T viewModel; + private T viewModel; internal T ViewModel { get => viewModel; set { @@ -41,18 +41,18 @@ namespace Xamarin.PropertyEditing.Mac public void OnViewModelChanged (T oldModel) { - listener.OnViewModelChanged (oldModel); + this.listener.OnViewModelChanged (oldModel); } public void OnPropertyChanged (object sender, PropertyChangedEventArgs e) { - listener.OnPropertyChanged (sender, e); + this.listener.OnPropertyChanged (sender, e); } public void Disconnect () { - if (viewModel != null) - viewModel.PropertyChanged -= OnPropertyChanged; + if (this.viewModel != null) + this.viewModel.PropertyChanged -= OnPropertyChanged; } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/NotifyingViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/NotifyingViewController.cs index 86c58d4..21eaa73 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/NotifyingViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/NotifyingViewController.cs @@ -13,16 +13,16 @@ namespace Xamarin.PropertyEditing.Mac class NotifyingViewController<T> : NSViewController, INotifyingListner<T> where T : NotifyingObject { internal T ViewModel { - get => adaptor.ViewModel; - set => adaptor.ViewModel = value; + get => Adaptor.ViewModel; + set => Adaptor.ViewModel = value; } public NotifyingViewController () { - adaptor = new NotifyingViewAdaptor<T> (this); + Adaptor = new NotifyingViewAdaptor<T> (this); } - protected NotifyingViewAdaptor<T> adaptor { get; } + protected NotifyingViewAdaptor<T> Adaptor { get; } public virtual void OnViewModelChanged (T oldModel) { diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs index c3715b7..756889f 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs @@ -21,7 +21,7 @@ namespace Xamarin.PropertyEditing.Mac public ValidationType NumericMode { get { return numericEditor.NumericMode; } set { - numericEditor.NumericMode = value; + this.numericEditor.NumericMode = value; Reset (); } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs index 38117de..95b44c8 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs @@ -9,7 +9,7 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - class ResourceDataSource : NSOutlineViewDataSource + internal class ResourceDataSource : NSOutlineViewDataSource { public ResourceDataSource (ResourceSelectorViewModel viewModel) : base () { @@ -60,7 +60,7 @@ namespace Xamarin.PropertyEditing.Mac private readonly Dictionary<object, NSObject> groupFacades = new Dictionary<object, NSObject> (); } - class ResourceBrushPropertyViewDelegate : ResourceOutlineViewDelegate + internal class ResourceBrushPropertyViewDelegate : ResourceOutlineViewDelegate { public BrushPropertyViewModel ViewModel { get; @@ -79,7 +79,7 @@ namespace Xamarin.PropertyEditing.Mac } } - class ResourceOutlineViewDelegate : NSOutlineViewDelegate + internal class ResourceOutlineViewDelegate : NSOutlineViewDelegate { public override NSView GetView (NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { @@ -115,7 +115,7 @@ namespace Xamarin.PropertyEditing.Mac } } - class ResourceOutlineView : NSOutlineView + internal class ResourceOutlineView : NSOutlineView { public ResourceOutlineView () { @@ -155,10 +155,10 @@ namespace Xamarin.PropertyEditing.Mac } } - class ResourceBrushViewController : NotifyingViewController<BrushPropertyViewModel> + internal class ResourceBrushViewController : NotifyingViewController<BrushPropertyViewModel> { - ResourceOutlineView resourceSelector; - ResourceBrushPropertyViewDelegate viewDelegate; + private ResourceOutlineView resourceSelector; + private ResourceBrushPropertyViewDelegate viewDelegate; public ResourceBrushViewController () { @@ -166,7 +166,7 @@ namespace Xamarin.PropertyEditing.Mac viewDelegate = new ResourceBrushPropertyViewDelegate (); } - Resource resource; + private Resource resource; public override void OnPropertyChanged (object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { @@ -186,7 +186,7 @@ namespace Xamarin.PropertyEditing.Mac } } - void UpdateSelection () + private void UpdateSelection () { if (resourceSelector == null) return; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ShadeLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ShadeLayer.cs index 0f44458..7a83418 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ShadeLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ShadeLayer.cs @@ -9,11 +9,11 @@ namespace Xamarin.PropertyEditing.Mac { class ShadeLayer : ColorEditorLayer { - const float GripRadius = 4; - const float BorderRadius = 3; - const float Margin = 3; - ChannelEditor saturationEditor = new HsbSaturationChannelEditor (); - ChannelEditor brightnessEditor = new HsbBrightnessChannelEditor (); + private const float GripRadius = 4; + private const float BorderRadius = 3; + private const float Margin = 3; + private readonly ChannelEditor saturationEditor = new HsbSaturationChannelEditor (); + private readonly ChannelEditor brightnessEditor = new HsbBrightnessChannelEditor (); public ShadeLayer () { @@ -38,13 +38,13 @@ namespace Xamarin.PropertyEditing.Mac { } - readonly CALayer grip = new UnanimatedLayer { + private readonly CALayer grip = new UnanimatedLayer { BorderColor = new CGColor (1, 1, 1), BorderWidth = 1, CornerRadius = GripRadius, }; - readonly CAGradientLayer brightnessLayer = new UnanimatedGradientLayer { + private readonly CAGradientLayer brightnessLayer = new UnanimatedGradientLayer { Colors = new [] { new CGColor (0f, 0f, 0f, 1f), new CGColor (0f, 0f, 0f, 0f) @@ -52,7 +52,7 @@ namespace Xamarin.PropertyEditing.Mac CornerRadius = BorderRadius, }; - readonly CAGradientLayer saturationLayer = new UnanimatedGradientLayer { + private readonly CAGradientLayer saturationLayer = new UnanimatedGradientLayer { Colors = new [] { new CGColor (1f, 1f, 1f), new CGColor (1f, .3f, 0f) @@ -68,10 +68,10 @@ namespace Xamarin.PropertyEditing.Mac { base.LayoutSublayers (); - saturationLayer.Frame = Bounds.Inset (Margin, Margin); - brightnessLayer.Frame = saturationLayer.Bounds; - saturationLayer.StartPoint = new CGPoint (0, .5); - saturationLayer.EndPoint = new CGPoint (1, .5); + this.saturationLayer.Frame = Bounds.Inset (Margin, Margin); + this.brightnessLayer.Frame = this.saturationLayer.Bounds; + this.saturationLayer.StartPoint = new CGPoint (0, .5); + this.saturationLayer.EndPoint = new CGPoint (1, .5); } public override void UpdateFromModel (EditorInteraction interaction) @@ -79,16 +79,16 @@ namespace Xamarin.PropertyEditing.Mac LayoutIfNeeded (); var color = interaction.Color; - var sat = saturationEditor.LocationFromColor (saturationLayer, color); - var bright = brightnessEditor.LocationFromColor (brightnessLayer, color); + var sat = this.saturationEditor.LocationFromColor (this.saturationLayer, color); + var bright = this.brightnessEditor.LocationFromColor (this.brightnessLayer, color); var x = sat.X; - var y = bright.Y + saturationLayer.Frame.Y; + var y = bright.Y + this.saturationLayer.Frame.Y; grip.Frame = new CGRect (x - GripRadius, y - GripRadius, GripRadius * 2, GripRadius * 2); var hueColor = interaction.Color.HueColor; - saturationEditor.UpdateGradientLayer (saturationLayer, hueColor); + this.saturationEditor.UpdateGradientLayer (this.saturationLayer, hueColor); } public override void UpdateFromLocation (EditorInteraction interaction, CGPoint location) @@ -98,15 +98,14 @@ namespace Xamarin.PropertyEditing.Mac if (interaction.ViewModel == null) return; - + var color = interaction.Color; - var saturation = saturationEditor.ValueFromLocation (saturationLayer, loc); - var brightness = saturationEditor.ValueFromLocation ( - brightnessLayer, + var saturation = this.saturationEditor.ValueFromLocation (this.saturationLayer, loc); + var brightness = this.saturationEditor.ValueFromLocation ( + this.brightnessLayer, new CGPoint (loc.X + brightnessLayer.Frame.X, loc.Y + brightnessLayer.Frame.Y)); - + interaction.Color = interaction.Color.UpdateHSB (saturation: saturation, brightness: brightness); - //interaction.Shade = shade; } public override void Commit (EditorInteraction interaction) diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs index 6574552..cba853a 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs @@ -12,7 +12,7 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - class EditorInteraction : NotifyingObject + internal class EditorInteraction : NotifyingObject { public EditorInteraction (SolidBrushViewModel viewModel, ColorEditorLayer layer) { @@ -37,11 +37,10 @@ namespace Xamarin.PropertyEditing.Mac } } - class SolidColorBrushEditor :ColorEditorView + internal class SolidColorBrushEditor : ColorEditorView { public SolidColorBrushEditor (IntPtr handle) : base (handle) { - Initialize (); } public SolidColorBrushEditor (CGRect frame) : base (frame) @@ -54,7 +53,7 @@ namespace Xamarin.PropertyEditing.Mac Initialize (); } - void Initialize () + private void Initialize () { Layer = new CALayer (); Layer.AddSublayer (background); @@ -66,27 +65,27 @@ namespace Xamarin.PropertyEditing.Mac AddSubview (componentTabs.View); } - readonly ColorComponentTabViewController componentTabs = new ColorComponentTabViewController () { + private readonly ColorComponentTabViewController componentTabs = new ColorComponentTabViewController () { EditorType = ChannelEditorType.RGB }; public override bool AcceptsFirstResponder () => true; - readonly ShadeLayer shadeLayer = new ShadeLayer (); - readonly HueLayer hueLayer = new HueLayer (); - readonly HistoryLayer historyLayer = new HistoryLayer (); + private readonly ShadeLayer shadeLayer = new ShadeLayer (); + private readonly HueLayer hueLayer = new HueLayer (); + private readonly HistoryLayer historyLayer = new HistoryLayer (); - readonly CALayer background = new CALayer { + private readonly CALayer background = new CALayer { CornerRadius = 3, BorderWidth = 1 }; - readonly CALayer componentBackground = new CALayer { + private readonly CALayer componentBackground = new CALayer { CornerRadius = 3, BorderWidth = 1 }; - EditorInteraction interaction; + private EditorInteraction interaction; public override void UpdateFromEvent (NSEvent theEvent) { } @@ -113,7 +112,7 @@ namespace Xamarin.PropertyEditing.Mac } } - CGPoint last; + private CGPoint last; public override void MouseDragged (NSEvent theEvent) { var location = ConvertPointFromView (theEvent.LocationInWindow, null); @@ -136,20 +135,20 @@ namespace Xamarin.PropertyEditing.Mac interaction = null; } - bool modelChanged = true; - protected override void OnPropertyChanged (object sender, PropertyChangedEventArgs e) + private bool modelChanged = true; + public override void OnPropertyChanged (object sender, PropertyChangedEventArgs e) { var inter = interaction ?? new EditorInteraction (ViewModel, null); switch (e.PropertyName) { case nameof (SolidBrushViewModel.Color): case nameof (SolidBrushViewModel.LastColor): - modelChanged = NeedsLayout = true; + this.modelChanged = NeedsLayout = true; break; } } - protected override void OnViewModelChanged (SolidBrushViewModel oldModel) + public override void OnViewModelChanged (SolidBrushViewModel oldModel) { base.OnViewModelChanged (oldModel); var inter = interaction ?? new EditorInteraction (ViewModel, null); @@ -162,12 +161,12 @@ namespace Xamarin.PropertyEditing.Mac public override void Layout () { - if (modelChanged) { + if (this.modelChanged) { var interx = interaction ?? new EditorInteraction (ViewModel, null); foreach (var editor in Layer.Sublayers.OfType<ColorEditorLayer> ()) { editor.UpdateFromModel (interx); } - modelChanged = false; + this.modelChanged = false; } base.Layout (); @@ -181,28 +180,28 @@ namespace Xamarin.PropertyEditing.Mac var secondBase = padding + secondarySpan; var firstStop = firstBase + primarySpan; - background.BorderColor = new CGColor (.5f, .5f, .5f, .5f); - background.BackgroundColor = NSColor.ControlBackground.CGColor; - background.Frame = new CGRect (0, 0, Frame.Height, Frame.Height); + this.background.BorderColor = new CGColor (.5f, .5f, .5f, .5f); + this.background.BackgroundColor = NSColor.ControlBackground.CGColor; + this.background.Frame = new CGRect (0, 0, Frame.Height, Frame.Height); - componentBackground.BorderColor = new CGColor (.5f, .5f, .5f, .5f); - componentBackground.BackgroundColor = NSColor.ControlBackground.CGColor; - componentBackground.Frame = new CGRect (0, 0, Frame.Height, Frame.Height); + this.componentBackground.BorderColor = new CGColor (.5f, .5f, .5f, .5f); + this.componentBackground.BackgroundColor = NSColor.ControlBackground.CGColor; + this.componentBackground.Frame = new CGRect (0, 0, Frame.Height, Frame.Height); var x = Frame.Height + 4 * padding; - componentBackground.Frame = new CGRect (Frame.Height + 4 * padding, 0, Frame.Width - x, Frame.Height); + this.componentBackground.Frame = new CGRect (Frame.Height + 4 * padding, 0, Frame.Width - x, Frame.Height); - hueLayer.Frame = new CGRect (firstStop, secondBase, secondarySpan, primarySpan); - hueLayer.GripColor = NSColor.Text.CGColor; + this.hueLayer.Frame = new CGRect (firstStop, secondBase, secondarySpan, primarySpan); + this.hueLayer.GripColor = NSColor.Text.CGColor; - shadeLayer.Frame = new CGRect (firstBase, secondBase, primarySpan, primarySpan); - historyLayer.Frame = new CGRect (firstBase, firstBase, primarySpan, secondarySpan); + this.shadeLayer.Frame = new CGRect (firstBase, secondBase, primarySpan, primarySpan); + this.historyLayer.Frame = new CGRect (firstBase, firstBase, primarySpan, secondarySpan); var inter = interaction ?? new EditorInteraction (ViewModel, null); foreach (var editor in Layer.Sublayers.OfType<ColorEditorLayer> ()) { editor.UpdateFromModel (inter); } - componentTabs.View.Frame = componentBackground.Frame.Inset (4 * padding, 2 * padding); + this.componentTabs.View.Frame = this.componentBackground.Frame.Inset (4 * padding, 2 * padding); } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditorViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditorViewController.cs index 3182876..965ac0d 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditorViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditorViewController.cs @@ -7,7 +7,7 @@ namespace Xamarin.PropertyEditing.Mac { class SolidColorBrushEditorViewController : NotifyingViewController<BrushPropertyViewModel> { - SolidColorBrushEditor brushEditor; + private SolidColorBrushEditor brushEditor; public SolidColorBrushEditorViewController () { @@ -18,20 +18,20 @@ namespace Xamarin.PropertyEditing.Mac { switch (e.PropertyName) { case nameof (BrushPropertyViewModel.Solid): - if (brushEditor != null) - brushEditor.ViewModel = ViewModel.Solid; + if (this.brushEditor != null) + this.brushEditor.ViewModel = ViewModel.Solid; break; case nameof (BrushPropertyViewModel.Value): - if (brushEditor != null) - brushEditor.ViewModel = ViewModel.Solid; + if (this.brushEditor != null) + this.brushEditor.ViewModel = ViewModel.Solid; break; } } public override void OnViewModelChanged (BrushPropertyViewModel oldModel) { - if (brushEditor != null) - brushEditor.ViewModel = ViewModel?.Solid; + if (this.brushEditor != null) + this.brushEditor.ViewModel = ViewModel?.Solid; } public override void ViewDidLoad () @@ -39,12 +39,12 @@ namespace Xamarin.PropertyEditing.Mac base.ViewDidLoad (); if (ViewModel != null) - brushEditor.ViewModel = ViewModel?.Solid; + this.brushEditor.ViewModel = ViewModel?.Solid; } public override void LoadView () { - View = brushEditor = new SolidColorBrushEditor { + View = this.brushEditor = new SolidColorBrushEditor { ViewModel = ViewModel?.Solid }; } |