diff options
author | Eric Maupin <ermaup@microsoft.com> | 2019-01-03 22:44:37 +0300 |
---|---|---|
committer | Eric Maupin <ermaup@microsoft.com> | 2019-01-11 23:19:25 +0300 |
commit | 71ad75860e1c5b6c33163d390988dbfbf409b4ac (patch) | |
tree | 80f6ed1ac0a1a0face888e3481f802f4d328a312 /Xamarin.PropertyEditing.Mac/Controls | |
parent | 104acbcc9c62e1a90e9e43cb7630583cb2b49ca4 (diff) |
[mac] Revamp theming
This commit:
- Drops outdated CG* editors
- Drops ThemeManager
- Introduces IHostResourceProvider
- Moves all images to new API
- Starts implementing colors
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls')
51 files changed, 479 insertions, 458 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/BaseEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BaseEditorControl.cs index a3dfaff..5cabf77 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BaseEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BaseEditorControl.cs @@ -1,9 +1,8 @@ using System; using System.Collections; -using System.ComponentModel; + using AppKit; using CoreGraphics; -using System.Windows.Input; using Xamarin.PropertyEditing.Mac.Resources; @@ -23,9 +22,14 @@ namespace Xamarin.PropertyEditing.Mac public PropertyButton PropertyButton => this.propertyButton; - public BaseEditorControl () + public BaseEditorControl (IHostResourceProvider hostResources) { - this.propertyButton = new PropertyButton { + if (hostResources == null) + throw new ArgumentNullException (nameof (hostResources)); + + HostResources = hostResources; + + this.propertyButton = new PropertyButton (hostResources) { TranslatesAutoresizingMaskIntoConstraints = false }; @@ -41,13 +45,9 @@ namespace Xamarin.PropertyEditing.Mac AccessibilityHelp = LocalizationResources.AccessibilityActionButtonDescription, }; -#if DESIGNER_DEBUG - this.actionButton.Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("action-warning-16"); -#endif - this.actionButton.Activated += (object sender, EventArgs e) => { if (this.errorList != null) { - var Container = new ErrorMessageView (this.errorList); + var Container = new ErrorMessageView (HostResources, this.errorList); var errorMessagePopUp = new NSPopover { Behavior = NSPopoverBehavior.Semitransient, @@ -73,25 +73,16 @@ namespace Xamarin.PropertyEditing.Mac NSLayoutConstraint.Create (this.actionButton, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1f, DefaultActioButtonSize), NSLayoutConstraint.Create (this.actionButton, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, DefaultActioButtonSize), }); - - PropertyEditorPanel.ThemeManager.ThemeChanged += ThemeManager_ThemeChanged; - } - - protected override void Dispose (bool disposing) - { - if (disposing) { - PropertyEditorPanel.ThemeManager.ThemeChanged -= ThemeManager_ThemeChanged; - } } - void ThemeManager_ThemeChanged (object sender, EventArgs e) + public override void ViewDidChangeEffectiveAppearance () { - UpdateTheme (); + this.actionButton.Image = this.actionButton.Enabled ? HostResources.GetNamedImage ("action-warning-16") : null; } - protected void UpdateTheme () + protected IHostResourceProvider HostResources { - this.Appearance = PropertyEditorPanel.ThemeManager.CurrentAppearance; + get; } protected void SetErrors (IEnumerable errors) @@ -102,7 +93,7 @@ namespace Xamarin.PropertyEditing.Mac this.actionButton.Hidden = !this.actionButton.Enabled; // Using NSImageName.Caution for now, we can change this later at the designers behest - this.actionButton.Image = this.actionButton.Enabled ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("action-warning-16") : null; + this.actionButton.Image = this.actionButton.Enabled ? HostResources.GetNamedImage ("action-warning-16") : null; } void NotifyActionButtonClicked () diff --git a/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs index a1f5d3f..c2ceb06 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs @@ -17,11 +17,12 @@ namespace Xamarin.PropertyEditing.Mac public override NSView FirstKeyView => XEditor; public override NSView LastKeyView => YEditor.DecrementButton; - protected BasePointEditorControl () + protected BasePointEditorControl (IHostResourceProvider hostResources) + : base (hostResources) { XLabel = new UnfocusableTextField (); - XEditor = new NumericSpinEditor<T> { + XEditor = new NumericSpinEditor<T> (hostResources) { BackgroundColor = NSColor.Clear, Value = 0.0f }; @@ -29,7 +30,7 @@ namespace Xamarin.PropertyEditing.Mac YLabel = new UnfocusableTextField (); - YEditor = new NumericSpinEditor<T> { + YEditor = new NumericSpinEditor<T> (hostResources) { BackgroundColor = NSColor.Clear, Value = 0.0f }; @@ -48,7 +49,13 @@ namespace Xamarin.PropertyEditing.Mac NSLayoutConstraint.Create (YEditor, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, DefaultControlHeight), }); - UpdateTheme (); + ViewDidChangeEffectiveAppearance (); + } + + public override void ViewDidChangeEffectiveAppearance () + { + XLabel.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); + YLabel.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); } protected override void HandleErrorsChanged (object sender, System.ComponentModel.DataErrorsChangedEventArgs e) diff --git a/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs index 97f9c05..81f9e2d 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs @@ -23,28 +23,29 @@ namespace Xamarin.PropertyEditing.Mac public override NSView FirstKeyView => XEditor; public override NSView LastKeyView => HeightEditor.DecrementButton; - protected BaseRectangleEditorControl () + protected BaseRectangleEditorControl (IHostResourceProvider hostResources) + : base (hostResources) { XLabel = new UnfocusableTextField (); - XEditor = new NumericSpinEditor<T> (); + XEditor = new NumericSpinEditor<T> (hostResources); XEditor.BackgroundColor = NSColor.Clear; XEditor.Value = 0.0f; XEditor.ValueChanged += OnInputUpdated; YLabel = new UnfocusableTextField (); - YEditor = new NumericSpinEditor<T> (); + YEditor = new NumericSpinEditor<T> (hostResources); YEditor.BackgroundColor = NSColor.Clear; YEditor.Value = 0.0f; YEditor.ValueChanged += OnInputUpdated; WidthLabel = new UnfocusableTextField (); - WidthEditor = new NumericSpinEditor<T> (); + WidthEditor = new NumericSpinEditor<T> (hostResources); WidthEditor.BackgroundColor = NSColor.Clear; WidthEditor.Value = 0.0f; WidthEditor.ValueChanged += OnInputUpdated; HeightLabel = new UnfocusableTextField (); - HeightEditor = new NumericSpinEditor<T> (); + HeightEditor = new NumericSpinEditor<T> (hostResources); HeightEditor.BackgroundColor = NSColor.Clear; HeightEditor.Value = 0.0f; HeightEditor.ValueChanged += OnInputUpdated; @@ -72,7 +73,17 @@ namespace Xamarin.PropertyEditing.Mac NSLayoutConstraint.Create (HeightEditor, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, DefaultControlHeight), }); - UpdateTheme (); + ViewDidChangeEffectiveAppearance (); + } + + public override void ViewDidChangeEffectiveAppearance () + { + XLabel.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); + YLabel.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); + WidthLabel.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); + HeightLabel.TextColor = HostResources.GetNamedColor (NamedResources.DescriptionLabelColor); + + base.ViewDidChangeEffectiveAppearance (); } protected virtual void OnInputUpdated (object sender, EventArgs e) diff --git a/Xamarin.PropertyEditing.Mac/Controls/BooleanEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BooleanEditorControl.cs index 887443e..2065ba5 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BooleanEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BooleanEditorControl.cs @@ -6,11 +6,13 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - internal class BooleanEditorControl : PropertyEditorControl<PropertyViewModel<bool?>> + internal class BooleanEditorControl
+ : PropertyEditorControl<PropertyViewModel<bool?>> { const string setBezelColorSelector = "setBezelColor:"; - public BooleanEditorControl () + public BooleanEditorControl (IHostResourceProvider hostResource)
+ : base (hostResource) { BooleanEditor = new NSButton { AllowsMixedState = true, @@ -39,8 +41,6 @@ namespace Xamarin.PropertyEditing.Mac NSLayoutConstraint.Create (BooleanEditor, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 6f), NSLayoutConstraint.Create (BooleanEditor, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 1f, -50f), }); - - UpdateTheme (); } internal NSButton BooleanEditor { get; set; } diff --git a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs index 91cc77e..906ddea 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs @@ -49,13 +49,18 @@ namespace Xamarin.PropertyEditing.Mac internal class BrushEditorControl : PropertyEditorControl<BrushPropertyViewModel> { - public BrushEditorControl () + public BrushEditorControl (IHostResourceProvider hostResources) + : base (hostResources) { TranslatesAutoresizingMaskIntoConstraints = false; + this.previewLayer = new CommonBrushLayer (hostResources) { + Frame = new CGRect (0, 0, 30, 10) + }; + this.popover = new NSPopover { Behavior = NSPopoverBehavior.Transient, - ContentViewController = this.brushTabViewController = new BrushTabViewController { + ContentViewController = this.brushTabViewController = new BrushTabViewController (hostResources) { PreferredContentSize = new CGSize (430, 263) } }; @@ -75,8 +80,6 @@ namespace Xamarin.PropertyEditing.Mac NSLayoutConstraint.Create (this.popUpButton, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 1f, -33f), NSLayoutConstraint.Create (this.popUpButton, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, DefaultControlHeight - 3), }); - - UpdateTheme (); } @@ -84,9 +87,7 @@ namespace Xamarin.PropertyEditing.Mac readonly NSPopover popover; readonly BrushTabViewController brushTabViewController; readonly NSMenu popupButtonList; - readonly CommonBrushLayer previewLayer = new CommonBrushLayer { - Frame = new CGRect (0, 0, 30, 10) - }; + readonly CommonBrushLayer previewLayer; public override NSView FirstKeyView => this.popUpButton; public override NSView LastKeyView => this.popUpButton; diff --git a/Xamarin.PropertyEditing.Mac/Controls/CGPointEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/CGPointEditorControl.cs deleted file mode 100644 index 6042ff4..0000000 --- a/Xamarin.PropertyEditing.Mac/Controls/CGPointEditorControl.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections; -using System.Diagnostics; -using System.Drawing; -using AppKit; -using CoreGraphics; -using Foundation; -using Xamarin.PropertyEditing.Mac.Resources; -using Xamarin.PropertyEditing.ViewModels; - -namespace Xamarin.PropertyEditing.Mac -{ - internal class CGPointEditorControl : PointEditorControl<CGPoint> - { - protected override void OnInputUpdated (object sender, EventArgs e) - { - ViewModel.Value = new CGPoint (XEditor.Value, YEditor.Value); - } - - protected override void UpdateValue () - { - XEditor.Value = ViewModel.Value.X; - YEditor.Value = ViewModel.Value.Y; - } - } -} diff --git a/Xamarin.PropertyEditing.Mac/Controls/CGRectEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/CGRectEditorControl.cs deleted file mode 100644 index 4b992d3..0000000 --- a/Xamarin.PropertyEditing.Mac/Controls/CGRectEditorControl.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using CoreGraphics; - -namespace Xamarin.PropertyEditing.Mac -{ - internal class CGRectEditorControl - : RectangleEditorControl<CGRect> - { - protected override void OnInputUpdated (object sender, EventArgs e) - { - ViewModel.Value = new CGRect (XEditor.Value, YEditor.Value, WidthEditor.Value, HeightEditor.Value); - } - - protected override void UpdateValue () - { - XEditor.Value = ViewModel.Value.X; - YEditor.Value = ViewModel.Value.Y; - WidthEditor.Value = ViewModel.Value.Width; - HeightEditor.Value = ViewModel.Value.Height; - } - } -}
\ No newline at end of file diff --git a/Xamarin.PropertyEditing.Mac/Controls/CGSizeEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/CGSizeEditorControl.cs deleted file mode 100644 index 34a0de4..0000000 --- a/Xamarin.PropertyEditing.Mac/Controls/CGSizeEditorControl.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections; -using System.Diagnostics; -using System.Drawing; -using AppKit; -using CoreGraphics; -using Foundation; -using Xamarin.PropertyEditing.Mac.Resources; -using Xamarin.PropertyEditing.ViewModels; - -namespace Xamarin.PropertyEditing.Mac -{ - internal class CGSizeEditorControl : SizeEditorControl<CGSize> - { - protected override void OnInputUpdated (object sender, EventArgs e) - { - ViewModel.Value = new CGSize (XEditor.Value, YEditor.Value); - } - - protected override void UpdateValue () - { - XEditor.Value = ViewModel.Value.Width; - YEditor.Value = ViewModel.Value.Height; - } - } -} diff --git a/Xamarin.PropertyEditing.Mac/Controls/CombinablePropertyEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/CombinablePropertyEditor.cs index 83bc60a..cf58bdc 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/CombinablePropertyEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/CombinablePropertyEditor.cs @@ -17,11 +17,10 @@ namespace Xamarin.PropertyEditing.Mac internal class CombinablePropertyEditor<T> : PropertyEditorControl<CombinablePropertyViewModel<T>> { - public CombinablePropertyEditor () + public CombinablePropertyEditor (IHostResourceProvider hostResources) + : base (hostResources) { base.TranslatesAutoresizingMaskIntoConstraints = false; - - UpdateTheme (); } public override NSView FirstKeyView => this.firstKeyView; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs index f8f3c54..76868b6 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs @@ -8,18 +8,22 @@ namespace Xamarin.PropertyEditing.Mac { const int DefaultIconButtonSize = 32; - public BasePopOverControl (string title, string imageNamed) : base () + public BasePopOverControl (IHostResourceProvider hostResources, string title, string imageNamed) : base () { if (title == null) throw new ArgumentNullException (nameof (title)); if (imageNamed == null) throw new ArgumentNullException (nameof (imageNamed)); + if (hostResources == null) + throw new ArgumentNullException (nameof (hostResources)); TranslatesAutoresizingMaskIntoConstraints = false; WantsLayer = true; + HostResources = hostResources; + var iconView = new NSImageView { - Image = PropertyEditorPanel.ThemeManager.GetImageForTheme (imageNamed), + Image = hostResources.GetNamedImage (imageNamed), ImageScaling = NSImageScale.None, TranslatesAutoresizingMaskIntoConstraints = false, }; @@ -46,8 +50,12 @@ namespace Xamarin.PropertyEditing.Mac NSLayoutConstraint.Create (viewTitle, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1f, 120), NSLayoutConstraint.Create (viewTitle, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, PropertyEditorControl.DefaultControlHeight), }); + } - Appearance = PropertyEditorPanel.ThemeManager.CurrentAppearance; + protected IHostResourceProvider HostResources + { + get; + private set; } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverViewModelControl.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverViewModelControl.cs index 85352f5..0f1846a 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverViewModelControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverViewModelControl.cs @@ -9,7 +9,8 @@ namespace Xamarin.PropertyEditing.Mac { internal PropertyViewModel ViewModel { get; } - public BasePopOverViewModelControl (PropertyViewModel viewModel, string title, string imageNamed) : base (title, imageNamed) + public BasePopOverViewModelControl (IHostResourceProvider hostResources, PropertyViewModel viewModel, string title, string imageNamed) + : base (hostResources, title, imageNamed) { if (viewModel == null) throw new ArgumentNullException (nameof (viewModel)); diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs index 37b8e4a..52b9c31 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs @@ -13,7 +13,8 @@ namespace Xamarin.PropertyEditing.Mac internal class BrushTabViewController : UnderlinedTabViewController<BrushPropertyViewModel>, IEditorView { - public BrushTabViewController () + public BrushTabViewController (IHostResourceProvider hostResources)
+ : base (hostResources) { PreferredContentSize = new CGSize (430, 230); TransitionOptions = NSViewControllerTransitionOptions.None; @@ -86,7 +87,7 @@ namespace Xamarin.PropertyEditing.Mac switch (kvp.Value) { case CommonBrushType.Solid: - var solid = new SolidColorBrushEditorViewController (); + var solid = new SolidColorBrushEditorViewController (HostResources); solid.ViewModel = ViewModel; item.ViewController = solid; item.ToolTip = Properties.Resources.SolidBrush; @@ -94,7 +95,7 @@ namespace Xamarin.PropertyEditing.Mac break;
case CommonBrushType.MaterialDesign: - var material = new MaterialBrushEditorViewController (); + var material = new MaterialBrushEditorViewController (HostResources); material.ViewModel = ViewModel; item.ViewController = material; item.ToolTip = Properties.Resources.MaterialDesignColorBrush; @@ -102,7 +103,7 @@ namespace Xamarin.PropertyEditing.Mac break;
case CommonBrushType.Resource: - this.resource = new ResourceBrushViewController (); + this.resource = new ResourceBrushViewController (HostResources); this.resource.ViewModel = ViewModel; item.ViewController = this.resource; item.ToolTip = Properties.Resources.ResourceBrush; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs index 9171e2b..8e9b9cb 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs @@ -20,16 +20,17 @@ namespace Xamarin.PropertyEditing.Mac public bool ClickableGradients { get; set; } = true; - public ColorComponentEditor (ChannelEditorType editorType, CGRect frame) : base (frame) + public ColorComponentEditor (IHostResourceProvider hostResources, ChannelEditorType editorType, CGRect frame) + : base (frame) { EditorType = EditorType; - Initialize (); + Initialize (hostResources); } - public ColorComponentEditor (ChannelEditorType editorType) : base () + public ColorComponentEditor (IHostResourceProvider hostResources, ChannelEditorType editorType) { EditorType = editorType; - Initialize (); + Initialize (hostResources); } private ChannelGroup [] Editors { get; set; } @@ -43,7 +44,7 @@ namespace Xamarin.PropertyEditing.Mac public CAGradientLayer Gradient { get; set; } } - private ChannelGroup CreateEditor (ChannelEditor editor) + private ChannelGroup CreateEditor (IHostResourceProvider hostResources, ChannelEditor editor) { var ce = new ChannelGroup { Label = new UnfocusableTextField { @@ -51,7 +52,7 @@ namespace Xamarin.PropertyEditing.Mac Alignment = NSTextAlignment.Right, ToolTip = editor.ToolTip }, - Editor = new ComponentSpinEditor (editor) { + Editor = new ComponentSpinEditor (hostResources, editor) { BackgroundColor = NSColor.Clear, TranslatesAutoresizingMaskIntoConstraints = true }, @@ -71,46 +72,46 @@ namespace Xamarin.PropertyEditing.Mac return ce; } - private ChannelGroup [] CreateEditors (ChannelEditorType type) + private ChannelGroup [] CreateEditors (IHostResourceProvider hostResources, ChannelEditorType type) { switch (type) { case ChannelEditorType.HSB: return new [] { - CreateEditor (new HsbHueChannelEditor ()), - CreateEditor (new HsbSaturationChannelEditor ()), - CreateEditor (new HsbBrightnessChannelEditor ()), - CreateEditor (new HsbAlphaChannelEditor ()) + CreateEditor (hostResources, new HsbHueChannelEditor ()), + CreateEditor (hostResources, new HsbSaturationChannelEditor ()), + CreateEditor (hostResources, new HsbBrightnessChannelEditor ()), + CreateEditor (hostResources, new HsbAlphaChannelEditor ()) }; case ChannelEditorType.HLS: return new [] { - CreateEditor (new HlsHueChannelEditor ()), - CreateEditor (new HlsLightnessChannelEditor ()), - CreateEditor (new HlsSaturationChannelEditor ()), - CreateEditor (new HlsAlphaChannelEditor ()) + CreateEditor (hostResources, new HlsHueChannelEditor ()), + CreateEditor (hostResources, new HlsLightnessChannelEditor ()), + CreateEditor (hostResources, new HlsSaturationChannelEditor ()), + CreateEditor (hostResources, new HlsAlphaChannelEditor ()) }; case ChannelEditorType.RGB: return new [] { - CreateEditor (new RedChannelEditor ()), - CreateEditor (new GreenChannelEditor ()), - CreateEditor (new BlueChannelEditor ()), - CreateEditor (new AlphaChannelEditor ()) + CreateEditor (hostResources, new RedChannelEditor ()), + CreateEditor (hostResources, new GreenChannelEditor ()), + CreateEditor (hostResources, new BlueChannelEditor ()), + CreateEditor (hostResources, new AlphaChannelEditor ()) }; default: case ChannelEditorType.CMYK: return new [] { - CreateEditor (new CyanChannelEditor ()), - CreateEditor (new MagentaChannelEditor ()), - CreateEditor (new YellowChannelEditor ()), - CreateEditor (new BlackChannelEditor ()), - CreateEditor (new AlphaChannelEditor ()) + CreateEditor (hostResources, new CyanChannelEditor ()), + CreateEditor (hostResources, new MagentaChannelEditor ()), + CreateEditor (hostResources, new YellowChannelEditor ()), + CreateEditor (hostResources, new BlackChannelEditor ()), + CreateEditor (hostResources, new AlphaChannelEditor ()) }; } } - private void Initialize () + private void Initialize (IHostResourceProvider hostResources) { WantsLayer = true; - Editors = CreateEditors (EditorType); + Editors = CreateEditors (hostResources, EditorType); this.hexLabel = new UnfocusableTextField { StringValue = "#:", diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentTabViewController.cs index 55c592c..7cb3b09 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentTabViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentTabViewController.cs @@ -6,16 +6,18 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - internal class ColorComponentTabViewController : UnderlinedTabViewController<SolidBrushViewModel> + internal class ColorComponentTabViewController + : UnderlinedTabViewController<SolidBrushViewModel> { - public ColorComponentTabViewController () + public ColorComponentTabViewController (IHostResourceProvider hostResources) + : base (hostResources) { foreach (var value in Enum.GetValues (typeof (ChannelEditorType))) { var editorType = (ChannelEditorType)value; AddTabViewItem (new NSTabViewItem { Label = value.ToString (), ToolTip = GetToolTip (editorType), - ViewController = new ColorComponentViewController (editorType) + ViewController = new ColorComponentViewController (hostResources, editorType) }); } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs index 1b3e93b..67c5b86 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs @@ -6,12 +6,15 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - internal class ColorComponentViewController : NotifyingViewController<SolidBrushViewModel> + internal class ColorComponentViewController + : NotifyingViewController<SolidBrushViewModel> { - private ColorComponentEditor editor; - - public ColorComponentViewController (ChannelEditorType type) : base () + public ColorComponentViewController (IHostResourceProvider hostResources, ChannelEditorType type) { + if (hostResources == null) + throw new ArgumentNullException (nameof (hostResources)); + + this.hostResources = hostResources; PreferredContentSize = new CGSize (100, 400); EditorType = type; } @@ -38,7 +41,10 @@ namespace Xamarin.PropertyEditing.Mac public override void LoadView () { - View = this.editor = new ColorComponentEditor (this.EditorType); + View = this.editor = new ColorComponentEditor (this.hostResources, EditorType); } + + private readonly IHostResourceProvider hostResources; + private ColorComponentEditor editor; } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushLayer.cs index c12362c..12f16b1 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushLayer.cs @@ -6,13 +6,19 @@ using Xamarin.PropertyEditing.Drawing; namespace Xamarin.PropertyEditing.Mac { - internal class CommonBrushLayer : CALayer + internal class CommonBrushLayer + : CALayer { - public CommonBrushLayer () + public CommonBrushLayer (IHostResourceProvider hostResources) { - this.CornerRadius = 3; - this.BorderColor = new CGColor (.5f, .5f, .5f, .5f); - this.BorderWidth = 1; + if (hostResources == null) + throw new ArgumentNullException (nameof (hostResources)); + + this.hostResources = hostResources; + + CornerRadius = 3; + BorderColor = new CGColor (.5f, .5f, .5f, .5f); + BorderWidth = 1; MasksToBounds = true; } @@ -63,7 +69,7 @@ namespace Xamarin.PropertyEditing.Mac { base.LayoutSublayers (); BrushLayer.Frame = Bounds; - Contents = DrawingExtensions.GenerateCheckerboard (Bounds); + Contents = DrawingExtensions.GenerateCheckerboard (Bounds, this.hostResources.GetNamedColor (NamedResources.Checkerboard0Color), this.hostResources.GetNamedColor (NamedResources.Checkerboard0Color)); } public NSImage RenderPreview () @@ -84,5 +90,7 @@ namespace Xamarin.PropertyEditing.Mac } } } + + private readonly IHostResourceProvider hostResources; } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushView.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushView.cs index d637b6d..0201795 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushView.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushView.cs @@ -15,18 +15,15 @@ namespace Xamarin.PropertyEditing.Mac NSView IValueView.NativeView => this; - public CommonBrushView () + public CommonBrushView (IHostResourceProvider hostResources) { - Initialize (); + Initialize (hostResources); } - public CommonBrushView (CGRect frame) : base (frame) - { - Initialize (); - } - - public CommonBrushView (IntPtr handle) : base (handle) + public CommonBrushView (IHostResourceProvider hostResources, CGRect frame) + : base (frame) { + Initialize (hostResources); } void IValueView.SetValue (object value) @@ -38,10 +35,10 @@ namespace Xamarin.PropertyEditing.Mac Brush = brush; } - private void Initialize () { + private void Initialize (IHostResourceProvider hostResources) + { WantsLayer = true; - Layer = new CommonBrushLayer - { + Layer = new CommonBrushLayer (hostResources) { Brush = Brush }; } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ComponentSpinEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ComponentSpinEditor.cs index da63dc8..bc305e7 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ComponentSpinEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ComponentSpinEditor.cs @@ -2,9 +2,11 @@ namespace Xamarin.PropertyEditing.Mac { - internal class ComponentSpinEditor : NumericSpinEditor + internal class ComponentSpinEditor + : NumericSpinEditor { - public ComponentSpinEditor (ChannelEditor component) + public ComponentSpinEditor (IHostResourceProvider hostResources, ChannelEditor component) + : base (hostResources) { ComponentEditor = component; MinimumValue = component.MinimumValue; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/DrawingExtensions.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/DrawingExtensions.cs index 6bb5c15..3b983bc 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/DrawingExtensions.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/DrawingExtensions.cs @@ -8,31 +8,15 @@ namespace Xamarin.PropertyEditing.Mac { static class DrawingExtensions { - public static NSImage CreateSwatch (this CommonColor color, CGSize size) - { - bool dark = PropertyEditorPanel.ThemeManager.Theme == Themes.PropertyEditorTheme.Dark; - byte c0c = (byte)(dark ? 0x26: 0xff); - byte c1c = (byte)(dark ? 0x00 : 0xd9); - - var c0 = CIColor.FromCGColor (color.Blend (new CommonColor (c0c, c0c, c0c)).ToCGColor ()); - var c1 = CIColor.FromCGColor (color.Blend (new CommonColor (c1c, c1c, c1c)).ToCGColor ()); - - return CreateSwatch (color, size, c0, c1); - } + public static NSImage CreateSwatch (this CommonColor color, CGSize size, NSColor c0, NSColor c1) + => CreateSwatch (color, size, CIColor.FromCGColor (c0.CGColor), CIColor.FromCGColor (c1.CGColor)); 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); - public static CGImage GenerateCheckerboard (CGRect frame) + public static CGImage GenerateCheckerboard (CGRect frame, NSColor c0, NSColor c1) { - bool dark = PropertyEditorPanel.ThemeManager.Theme == Themes.PropertyEditorTheme.Dark; - float c1 = dark ? 0x26 / 255f : 1; - float c2 = dark ? 0 : 0xd9 / 255f; - - return DrawingExtensions.GenerateCheckerboard ( - frame, - CoreImage.CIColor.FromRgb (c1, c1, c1), - CoreImage.CIColor.FromRgb (c2, c2, c2)); + return GenerateCheckerboard (frame, CIColor.FromCGColor (c0.CGColor), CIColor.FromCGColor (c1.CGColor)); } public static CGImage GenerateCheckerboard (CGRect frame, CIColor c0, CIColor c1) diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/HistoryLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/HistoryLayer.cs index 84fcbcf..221f076 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/HistoryLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/HistoryLayer.cs @@ -1,4 +1,5 @@ using System; +using AppKit; using CoreAnimation; using CoreGraphics; @@ -9,8 +10,12 @@ namespace Xamarin.PropertyEditing.Mac private const float Margin = 3; private const float BorderRadius = 3; - public HistoryLayer () + public HistoryLayer (IHostResourceProvider hostResources) { + if (hostResources == null) + throw new ArgumentNullException (nameof (hostResources)); + + this.hostResources = hostResources; clip.AddSublayer (previous); clip.AddSublayer (current); AddSublayer (clip); @@ -22,6 +27,7 @@ namespace Xamarin.PropertyEditing.Mac { } + private readonly IHostResourceProvider hostResources; private readonly CALayer previous = new UnanimatedLayer (); private readonly CALayer current = new UnanimatedLayer (); private readonly CALayer last = new UnanimatedLayer (); @@ -56,8 +62,11 @@ namespace Xamarin.PropertyEditing.Mac Bounds.Width - Bounds.Height + Margin, Bounds.Height).Inset (Margin, Margin); - this.clip.Contents = DrawingExtensions.GenerateCheckerboard (this.clip.Bounds); - this.lastClip.Contents = DrawingExtensions.GenerateCheckerboard (this.last.Bounds); + NSColor cc0 = this.hostResources.GetNamedColor (NamedResources.Checkerboard0Color); + NSColor cc1 = this.hostResources.GetNamedColor (NamedResources.Checkerboard1Color); + + this.clip.Contents = DrawingExtensions.GenerateCheckerboard (this.clip.Bounds, cc0, cc1); + this.lastClip.Contents = DrawingExtensions.GenerateCheckerboard (this.last.Bounds, cc0, cc1); this.last.Frame = this.lastClip.Bounds; var width = clip.Frame.Width / 2; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs index 4cf164f..5920c75 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs @@ -7,17 +7,18 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - class MaterialBrushEditorViewController : NotifyingViewController<BrushPropertyViewModel> + internal class MaterialBrushEditorViewController + : NotifyingViewController<BrushPropertyViewModel> { - public MaterialBrushEditorViewController () + public MaterialBrushEditorViewController (IHostResourceProvider hostResources) { + if (hostResources == null) + throw new ArgumentNullException (nameof (hostResources)); + + this.hostResources = hostResources; PreferredContentSize = new CGSize (430, 230); } - private MaterialView materialEditor; - private AlphaChannelEditor alphaChannelEditor; - private ComponentSpinEditor alphaSpinEditor; - public override void OnPropertyChanged (object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { @@ -37,15 +38,6 @@ namespace Xamarin.PropertyEditing.Mac this.materialEditor.ViewModel = ViewModel?.MaterialDesign; } - void UpdateComponent (object sender, EventArgs args) - { - if (ViewModel == null) - return; - - var editor = sender as NumericSpinEditor; - ViewModel.MaterialDesign.Alpha = (byte)editor.Value; - } - public override void LoadView () { var stack = new NSStackView () { @@ -57,7 +49,7 @@ namespace Xamarin.PropertyEditing.Mac }; this.alphaChannelEditor = new AlphaChannelEditor (); - this.alphaSpinEditor = new ComponentSpinEditor (this.alphaChannelEditor) { + this.alphaSpinEditor = new ComponentSpinEditor (this.hostResources, this.alphaChannelEditor) { BackgroundColor = NSColor.Clear }; this.alphaSpinEditor.ValueChanged += UpdateComponent; @@ -80,5 +72,20 @@ namespace Xamarin.PropertyEditing.Mac View = stack; } + + private readonly IHostResourceProvider hostResources; + + private MaterialView materialEditor; + private AlphaChannelEditor alphaChannelEditor; + private ComponentSpinEditor alphaSpinEditor; + + private void UpdateComponent (object sender, EventArgs args) + { + if (ViewModel == null) + return; + + var editor = sender as NumericSpinEditor; + ViewModel.MaterialDesign.Alpha = (byte)editor.Value; + } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs index a3c68fd..b5034da 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs @@ -1,17 +1,22 @@ using System; + using AppKit; using CoreGraphics; using Foundation; -using Xamarin.PropertyEditing.Drawing; -using Xamarin.PropertyEditing.Themes; namespace Xamarin.PropertyEditing.Mac { - internal class NumericSpinEditor<T> : NumericSpinEditor + internal class NumericSpinEditor<T> + : NumericSpinEditor { + public NumericSpinEditor (IHostResourceProvider hostResources) + : base (hostResources) + { + } } - internal class NumericSpinEditor : NSView, INSAccessibilityGroup + internal class NumericSpinEditor + : NSView, INSAccessibilityGroup { const int stepperSpace = 2; const int stepperWidth = 11; @@ -24,13 +29,13 @@ namespace Xamarin.PropertyEditing.Mac get { return this.numericEditor; } } - private UpSpinnerButton incrementButton; - public UpSpinnerButton IncrementButton { + private SpinnerButton incrementButton; + public SpinnerButton IncrementButton { get { return this.incrementButton; } } - private DownSpinnerButton decrementButton; - public DownSpinnerButton DecrementButton { + private SpinnerButton decrementButton; + public SpinnerButton DecrementButton { get { return this.decrementButton; } } @@ -166,16 +171,19 @@ namespace Xamarin.PropertyEditing.Mac { } - public NumericSpinEditor () + public NumericSpinEditor (IHostResourceProvider hostResources) { + if (hostResources == null) + throw new ArgumentNullException (nameof (hostResources)); + + this.hostResources = hostResources; TranslatesAutoresizingMaskIntoConstraints = false; - var controlSize = NSControlSize.Small; - incrementButton = new UpSpinnerButton { + this.incrementButton = new SpinnerButton (this.hostResources, isUp: true) { TranslatesAutoresizingMaskIntoConstraints = false }; - decrementButton = new DownSpinnerButton { + this.decrementButton = new SpinnerButton (this.hostResources, isUp: false) { TranslatesAutoresizingMaskIntoConstraints = false }; @@ -188,13 +196,15 @@ namespace Xamarin.PropertyEditing.Mac NumberStyle = NSNumberFormatterStyle.Decimal, UsesGroupingSeparator = false }; - if (DisplayFormat != null) this.formatter.PositiveFormat = DisplayFormat; + + if (DisplayFormat != null) + this.formatter.PositiveFormat = DisplayFormat; this.numericEditor = new NumericTextField { Alignment = NSTextAlignment.Right, TranslatesAutoresizingMaskIntoConstraints = false, Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize), - ControlSize = controlSize, + ControlSize = NSControlSize.Small, Formatter = this.formatter }; @@ -224,27 +234,6 @@ namespace Xamarin.PropertyEditing.Mac NSLayoutConstraint.Create (this.decrementButton, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1f, stepperWidth), NSLayoutConstraint.Create (this.decrementButton, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, stepperBotHeight), }); - - PropertyEditorPanel.ThemeManager.ThemeChanged += ThemeManager_ThemeChanged; - - UpdateTheme (); - } - - protected override void Dispose (bool disposing) - { - if (disposing) { - PropertyEditorPanel.ThemeManager.ThemeChanged -= ThemeManager_ThemeChanged; - } - } - - void ThemeManager_ThemeChanged (object sender, EventArgs e) - { - UpdateTheme (); - } - - protected void UpdateTheme () - { - Appearance = PropertyEditorPanel.ThemeManager.CurrentAppearance; } virtual protected void OnEditingEnded (object sender, EventArgs e) @@ -306,5 +295,7 @@ namespace Xamarin.PropertyEditing.Mac { return (double)Decimal.Round ((decimal)(value < MinimumValue ? MinimumValue : value > MaximumValue ? MaximumValue : value), Digits); } + + private readonly IHostResourceProvider hostResources; } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs index a990d02..ef7e464 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs @@ -1,15 +1,13 @@ using System; -using System.Collections; -using System.ComponentModel; using AppKit; using CoreGraphics; using Xamarin.PropertyEditing.Mac.Resources; -using Xamarin.PropertyEditing.Themes; using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - public class PropertyButton : UnfocusableButton + public class PropertyButton + : UnfocusableButton { public const int DefaultSize = 20; @@ -31,12 +29,17 @@ namespace Xamarin.PropertyEditing.Mac } } - public PropertyButton () + public PropertyButton (IHostResourceProvider hostResources) { + if (hostResources == null) + throw new ArgumentNullException (nameof (hostResources)); + + this.hostResources = hostResources; + AccessibilityTitle = LocalizationResources.AccessibilityPropertiesButton; AccessibilityHelp = LocalizationResources.AccessibilityPropertiesButtonDescription; Enabled = true; - Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-default-mac-10"); + Image = this.hostResources.GetNamedImage ("property-button-default-mac-10"); ImageScaling = NSImageScale.None; ToolTip = Properties.Resources.Default; @@ -107,40 +110,41 @@ namespace Xamarin.PropertyEditing.Mac NSMenu.PopUpContextMenu (popUpContextMenu, popupMenuEvent, this); } - protected override void UpdateTheme () + public override void ViewDidChangeEffectiveAppearance () { - base.UpdateTheme (); - + base.ViewDidChangeEffectiveAppearance (); ToggleFocusImage (); } + private readonly IHostResourceProvider hostResources; + private void ToggleFocusImage (bool focused = false) { if (viewModel != null) { switch (viewModel.ValueSource) { case ValueSource.Binding: - Image = focused ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-bound-mac-active-10") : PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-bound-mac-10"); + Image = focused ? this.hostResources.GetNamedImage ("property-button-bound-mac-active-10") : this.hostResources.GetNamedImage ("property-button-bound-mac-10"); break; case ValueSource.Default: - Image = focused ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-default-mac-active-10") : PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-default-mac-10"); + Image = focused ? this.hostResources.GetNamedImage ("property-button-default-mac-active-10") : this.hostResources.GetNamedImage ("property-button-default-mac-10"); break; case ValueSource.Local: - Image = focused ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-local-mac-active-10") : PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-local-mac-10"); + Image = focused ? this.hostResources.GetNamedImage ("property-button-local-mac-active-10") : this.hostResources.GetNamedImage ("property-button-local-mac-10"); break; case ValueSource.Inherited: - Image = focused ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-inherited-mac-active-10") : PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-inherited-mac-10"); + Image = focused ? this.hostResources.GetNamedImage ("property-button-inherited-mac-active-10") : this.hostResources.GetNamedImage ("property-button-inherited-mac-10"); break; case ValueSource.Resource: - Image = focused ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-inherited-mac-active-10") : PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-inherited-mac-10"); + Image = focused ? this.hostResources.GetNamedImage ("property-button-inherited-mac-active-10") : this.hostResources.GetNamedImage ("property-button-inherited-mac-10"); break; case ValueSource.Unset: - Image = focused ? PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-default-mac-active-10") : PropertyEditorPanel.ThemeManager.GetImageForTheme ("property-button-default-mac-10"); + Image = focused ? this.hostResources.GetNamedImage ("property-button-default-mac-active-10") : this.hostResources.GetNamedImage ("property-button-default-mac-10"); break; default: @@ -183,8 +187,6 @@ namespace Xamarin.PropertyEditing.Mac ToolTip = string.Empty; break; } - - UpdateTheme (); } private void OnPropertyChanged (object sender, System.ComponentModel.PropertyChangedEventArgs e) @@ -196,7 +198,7 @@ namespace Xamarin.PropertyEditing.Mac private void OnCustomExpression (object sender, EventArgs e) { - var customExpressionView = new CustomExpressionView (viewModel); + var customExpressionView = new CustomExpressionView (this.hostResources, viewModel); var customExpressionPopOver = new AutoClosePopOver { ContentViewController = new NSViewController (null, null) { View = customExpressionView }, @@ -207,7 +209,7 @@ namespace Xamarin.PropertyEditing.Mac private void OnResourceRequested (object sender, EventArgs e) { - var requestResourceView = new RequestResourceView (this.viewModel); + var requestResourceView = new RequestResourceView (this.hostResources, this.viewModel); var resourceSelectorPopOver = new AutoClosePopOver { ContentViewController = new NSViewController (null, null) { View = requestResourceView }, diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/RatioEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/RatioEditor.cs index 8ba4df5..212c159 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/RatioEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/RatioEditor.cs @@ -10,7 +10,8 @@ namespace Xamarin.PropertyEditing.Mac { private bool fullSelection; - public RatioEditor () + public RatioEditor (IHostResourceProvider hostResources) + : base (hostResources) { AllowNegativeValues = false; AllowRatios = true; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushPropertyViewDelegate.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushPropertyViewDelegate.cs index 84f35dd..25dcee1 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushPropertyViewDelegate.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushPropertyViewDelegate.cs @@ -4,8 +4,14 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - internal class ResourceBrushPropertyViewDelegate : ResourceOutlineViewDelegate + internal class ResourceBrushPropertyViewDelegate + : ResourceOutlineViewDelegate { + public ResourceBrushPropertyViewDelegate (IHostResourceProvider hostResources) + : base (hostResources) + { + } + public BrushPropertyViewModel ViewModel { get; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs index a212024..82c0256 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs @@ -1,11 +1,7 @@ using System; -using System.Collections.Generic; using System.ComponentModel; using AppKit; using CoreGraphics; -using Foundation; -using Xamarin.PropertyEditing.Drawing; -using Xamarin.PropertyEditing.Mac.Resources; using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac @@ -13,12 +9,12 @@ namespace Xamarin.PropertyEditing.Mac internal class ResourceBrushViewController : NotifyingViewController<BrushPropertyViewModel> { private ResourceOutlineView resourceSelector; - private ResourceBrushPropertyViewDelegate viewDelegate; + private readonly ResourceBrushPropertyViewDelegate viewDelegate; - public ResourceBrushViewController () + public ResourceBrushViewController (IHostResourceProvider hostResources) { PreferredContentSize = new CGSize (430, 230); - viewDelegate = new ResourceBrushPropertyViewDelegate (); + this.viewDelegate = new ResourceBrushPropertyViewDelegate (hostResources); } private Resource resource; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceOutlineViewDelegate.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceOutlineViewDelegate.cs index 4df996b..2777c78 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceOutlineViewDelegate.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceOutlineViewDelegate.cs @@ -7,10 +7,16 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - internal class ResourceOutlineViewDelegate : NSOutlineViewDelegate + internal class ResourceOutlineViewDelegate + : NSOutlineViewDelegate { - private const string labelIdentifier = "label"; - private const string resourceIdentifier = "resource"; + public ResourceOutlineViewDelegate (IHostResourceProvider hostResource) + { + if (hostResource == null) + throw new ArgumentNullException (nameof (hostResource)); + + this.hostResources = hostResource; + } public override NSView GetView (NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { @@ -20,7 +26,7 @@ namespace Xamarin.PropertyEditing.Mac case ResourceOutlineView.ResourcePreviewColId: var cbv = (CommonBrushView)outlineView.MakeView (resourceIdentifier, this); if (cbv == null) { - cbv = new CommonBrushView { + cbv = new CommonBrushView (this.hostResources) { Identifier = resourceIdentifier, Frame = new CGRect (0, 0, 30, 10), }; @@ -50,5 +56,10 @@ namespace Xamarin.PropertyEditing.Mac { return PropertyEditorControl.DefaultControlHeight; } + + private const string labelIdentifier = "label"; + private const string resourceIdentifier = "resource"; + + private readonly IHostResourceProvider hostResources; } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs index 7813f5f..ddec36b 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs @@ -37,24 +37,29 @@ namespace Xamarin.PropertyEditing.Mac } } - internal class SolidColorBrushEditor : ColorEditorView + internal class SolidColorBrushEditor + : ColorEditorView { - public SolidColorBrushEditor (IntPtr handle) : base (handle) - { - } - public SolidColorBrushEditor (CGRect frame) : base (frame) + public SolidColorBrushEditor (IHostResourceProvider hostResources, CGRect frame) + : base (frame) { - Initialize (); + Initialize (hostResources); } - public SolidColorBrushEditor () : base () + public SolidColorBrushEditor (IHostResourceProvider hostResources) { - Initialize (); + Initialize (hostResources); } - private void Initialize () + private void Initialize (IHostResourceProvider hostResources) { + this.historyLayer = new HistoryLayer (hostResources); + + this.componentTabs = new ColorComponentTabViewController (hostResources) { + EditorType = ChannelEditorType.RGB + }; + Layer = new CALayer (); Layer.AddSublayer (background); Layer.AddSublayer (shadeLayer); @@ -65,15 +70,12 @@ namespace Xamarin.PropertyEditing.Mac AddSubview (componentTabs.View); } - private readonly ColorComponentTabViewController componentTabs = new ColorComponentTabViewController () { - EditorType = ChannelEditorType.RGB - }; - public override bool AcceptsFirstResponder () => true; private readonly ShadeLayer shadeLayer = new ShadeLayer (); private readonly HueLayer hueLayer = new HueLayer (); - private readonly HistoryLayer historyLayer = new HistoryLayer (); + private HistoryLayer historyLayer; + private ColorComponentTabViewController componentTabs; private readonly CALayer background = new CALayer { CornerRadius = 3, diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditorViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditorViewController.cs index a024dcc..dee1962 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditorViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditorViewController.cs @@ -5,12 +5,15 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - class SolidColorBrushEditorViewController : NotifyingViewController<BrushPropertyViewModel> + internal class SolidColorBrushEditorViewController + : NotifyingViewController<BrushPropertyViewModel> { - private SolidColorBrushEditor brushEditor; - - public SolidColorBrushEditorViewController () + public SolidColorBrushEditorViewController (IHostResourceProvider hostResources) { + if (hostResources == null) + throw new ArgumentNullException (nameof (hostResources)); + + this.hostResources = hostResources; PreferredContentSize = new CGSize (430, 230); } @@ -44,9 +47,12 @@ namespace Xamarin.PropertyEditing.Mac public override void LoadView () { - View = this.brushEditor = new SolidColorBrushEditor { + View = this.brushEditor = new SolidColorBrushEditor (this.hostResources) { ViewModel = ViewModel?.Solid }; } + + private readonly IHostResourceProvider hostResources; + private SolidColorBrushEditor brushEditor; } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs index 0ba72dc..027296c 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs @@ -1,49 +1,52 @@ using System; using AppKit; using ObjCRuntime; -using Xamarin.PropertyEditing.Themes; namespace Xamarin.PropertyEditing.Mac { - public class UpSpinnerButton : UnfocusableButton + internal class SpinnerButton + : UnfocusableButton { - public UpSpinnerButton () + public SpinnerButton (IHostResourceProvider hostResource, bool isUp) { - OnMouseEntered += (sender, e) => { - Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("stepper-up-focus-blue"); - }; + if (hostResource == null) + throw new ArgumentNullException (nameof (hostResource)); - OnMouseExited += (sender, e) => { - Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("stepper-up"); - }; + this.hostResources = hostResource; + this.imageBase += (isUp) ? "up" : "down"; } - protected override void UpdateTheme () + public override void MouseExited (NSEvent theEvent) { - base.UpdateTheme (); + this.isMouseOver = false; + UpdateImage (); + } - Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("stepper-up"); + public override void MouseEntered (NSEvent theEvent) + { + this.isMouseOver = true; + UpdateImage (); } - } - public class DownSpinnerButton : UnfocusableButton - { - public DownSpinnerButton () + public override void ViewDidChangeEffectiveAppearance () { - OnMouseEntered += (sender, e) => { - Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("stepper-down-focus-blue"); - }; + base.ViewDidChangeEffectiveAppearance (); + this.image = this.hostResources.GetNamedImage (this.imageBase); + this.mouseOverImage = this.hostResources.GetNamedImage (this.imageBase + "-focus-blue"); - OnMouseExited += (sender, e) => { - Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("stepper-down"); - }; + UpdateImage (); } - protected override void UpdateTheme () - { - base.UpdateTheme (); + private readonly IHostResourceProvider hostResources; + private bool isMouseOver; + private string imageBase = "stepper-"; + + private NSImage image; + private NSImage mouseOverImage; - Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("stepper-down"); + private void UpdateImage () + { + Image = (this.isMouseOver) ? this.mouseOverImage : Image; } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs index 4cff17e..0a32a71 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs @@ -9,6 +9,14 @@ namespace Xamarin.PropertyEditing.Mac : NotifyingTabViewController<TViewModel> where TViewModel : NotifyingObject {
+ public UnderlinedTabViewController (IHostResourceProvider hostResources) + {
+ if (hostResources == null)
+ throw new ArgumentNullException (nameof (hostResources));
+ + HostResources = hostResources; + }
+
public override void InsertTabViewItem (NSTabViewItem tabViewItem, nint index) {
this.tabStack.InsertView (GetView (tabViewItem), (nuint)index, NSStackViewGravity.Leading);
@@ -84,6 +92,11 @@ namespace Xamarin.PropertyEditing.Mac View = this.outerStack; }
+ protected IHostResourceProvider HostResources + { + get; + }
+
private IUnderliningTabView selected;
private NSStackView outerStack;
private NSStackView innerStack;
@@ -110,7 +123,7 @@ namespace Xamarin.PropertyEditing.Mac {
NSView tabView;
if (item.Identifier != null) {
- tabView = new UnderlinedImageView ((item.Identifier as NSString).ToString()) {
+ tabView = new UnderlinedImageView (HostResources, ((NSString)item.Identifier).ToString()) {
Selected = this.tabStack.Views.Length == SelectedTabViewItemIndex,
ToolTip = item.ToolTip
};
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs index 0c5f921..af60712 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs @@ -1,4 +1,5 @@ -using AppKit; +using System; +using AppKit; using CoreGraphics; namespace Xamarin.PropertyEditing.Mac @@ -10,13 +11,15 @@ namespace Xamarin.PropertyEditing.Mac internal class UnderlinedImageView : NSImageView, IUnderliningTabView { - public UnderlinedImageView (string name) + public UnderlinedImageView (IHostResourceProvider hostResources, string name) { + if (hostResources == null) + throw new ArgumentNullException (nameof (hostResources)); + + this.hostResources = hostResources; this.name = name; } - private string name; - private bool selected; public bool Selected { @@ -43,18 +46,9 @@ namespace Xamarin.PropertyEditing.Mac } } - - private string VersionName { - get { - return PropertyEditorPanel.ThemeManager.GetImageNameForTheme (this.name, this.selected); - } - } - public override void DrawRect (CGRect dirtyRect) { - if (Image?.Name != VersionName) { - Image = PropertyEditorPanel.ThemeManager.GetImageForTheme (this.name, this.selected); - } + Image = this.hostResources.GetNamedImage (this.name + ((Selected) ? "~sel" : String.Empty)); base.DrawRect (dirtyRect); if (!Selected) @@ -62,7 +56,7 @@ namespace Xamarin.PropertyEditing.Mac NSBezierPath path = new NSBezierPath (); path.AppendPathWithRect (new CGRect (Bounds.X, Bounds.Top + this.lineWidth, Bounds.Width, this.lineWidth)); - (selected? NSColor.Text: NSColor.DisabledControlText).Set (); + (Selected ? NSColor.Text: NSColor.DisabledControlText).Set (); path.Fill (); } @@ -73,6 +67,9 @@ namespace Xamarin.PropertyEditing.Mac return new CGSize (size.Width + this.lineWidth + 10, size.Height + this.lineWidth + 10); } } + + private readonly IHostResourceProvider hostResources; + private readonly string name; } internal class UnderlinedTextField : NSTextField, IUnderliningTabView diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableButton.cs index 27c4496..e00482d 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableButton.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableButton.cs @@ -16,19 +16,9 @@ namespace Xamarin.PropertyEditing.Mac { Enabled = true; ImageScaling = NSImageScale.AxesIndependently; - - PropertyEditorPanel.ThemeManager.ThemeChanged += ThemeManager_ThemeChanged; - - UpdateTheme (); } #region Overridden Methods - protected override void Dispose (bool disposing) - { - if (disposing) { - PropertyEditorPanel.ThemeManager.ThemeChanged -= ThemeManager_ThemeChanged; - } - } public override void MouseDown (NSEvent theEvent) { @@ -96,15 +86,6 @@ namespace Xamarin.PropertyEditing.Mac OnMouseRightDown?.Invoke (this, EventArgs.Empty); } - void ThemeManager_ThemeChanged (object sender, EventArgs e) - { - UpdateTheme (); - } - - protected virtual void UpdateTheme () - { - this.Appearance = PropertyEditorPanel.ThemeManager.CurrentAppearance; - } #endregion } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableTextField.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableTextField.cs index d3abc2a..cafad65 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableTextField.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableTextField.cs @@ -41,24 +41,15 @@ namespace Xamarin.PropertyEditing.Mac public UnfocusableTextField () { SetDefaultTextProperties (); - SetTheming (); } public UnfocusableTextField (CGRect frameRect, string text) : base (frameRect) { SetDefaultTextProperties (); - SetTheming (); StringValue = text; } - protected override void Dispose (bool disposing) - { - if (disposing) { - PropertyEditorPanel.ThemeManager.ThemeChanged -= ThemeManager_ThemeChanged; - } - } - private void SetDefaultTextProperties () { this.label = new NSTextField { @@ -84,22 +75,5 @@ namespace Xamarin.PropertyEditing.Mac NSLayoutConstraint.Create (this, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, this.label, NSLayoutAttribute.Trailing, 1f, 0f) }); } - - private void SetTheming () - { - PropertyEditorPanel.ThemeManager.ThemeChanged += ThemeManager_ThemeChanged; - - UpdateTheme (); - } - - private void ThemeManager_ThemeChanged (object sender, EventArgs e) - { - UpdateTheme (); - } - - protected void UpdateTheme () - { - Appearance = PropertyEditorPanel.ThemeManager.CurrentAppearance; - } } }
\ No newline at end of file diff --git a/Xamarin.PropertyEditing.Mac/Controls/CustomExpressionView.cs b/Xamarin.PropertyEditing.Mac/Controls/CustomExpressionView.cs index 4ac1973..18cb156 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/CustomExpressionView.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/CustomExpressionView.cs @@ -14,7 +14,8 @@ namespace Xamarin.PropertyEditing.Mac const string CustomExpressionPropertyString = "CustomExpression"; PropertyInfo customExpressionPropertyInfo; - public CustomExpressionView (PropertyViewModel viewModel) : base (viewModel, Properties.Resources.CustomExpression, "custom-expression-32") + public CustomExpressionView (IHostResourceProvider hostResources, PropertyViewModel viewModel) + : base (hostResources, viewModel, Properties.Resources.CustomExpression, "custom-expression-32") { Frame = new CGRect (CGPoint.Empty, new CGSize (250, 80)); diff --git a/Xamarin.PropertyEditing.Mac/Controls/EditorContainer.cs b/Xamarin.PropertyEditing.Mac/Controls/EditorContainer.cs index 9b4dc19..e5eec20 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/EditorContainer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/EditorContainer.cs @@ -6,8 +6,11 @@ namespace Xamarin.PropertyEditing.Mac internal class EditorContainer : NSView { - public EditorContainer (IEditorView editorView) + public EditorContainer (IHostResourceProvider hostResources, IEditorView editorView) { + if (hostResources == null) + throw new ArgumentNullException (nameof (hostResources)); + EditorView = editorView; AddSubview (this.label); @@ -50,5 +53,7 @@ namespace Xamarin.PropertyEditing.Mac set { this.label.TextColor = value; } } #endif + + private readonly IHostResourceProvider hostResources; } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/ErrorMessageView.cs b/Xamarin.PropertyEditing.Mac/Controls/ErrorMessageView.cs index 7089718..8f76498 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/ErrorMessageView.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/ErrorMessageView.cs @@ -13,7 +13,7 @@ namespace Xamarin.PropertyEditing.Mac private NSTextField errorMessages; - public ErrorMessageView (IEnumerable errors) + public ErrorMessageView (IHostResourceProvider hostResources, IEnumerable errors) { if (errors == null) throw new ArgumentNullException (nameof (errors)); @@ -22,7 +22,7 @@ namespace Xamarin.PropertyEditing.Mac var iconView = new NSButton (new CGRect (5, Frame.Height - 25, DefaultIconButtonSize, DefaultIconButtonSize)) { Bordered = false, - Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("action-warning-16"), + Image = hostResources.GetNamedImage ("action-warning-16"), Title = string.Empty, TranslatesAutoresizingMaskIntoConstraints = false, }; @@ -62,8 +62,6 @@ namespace Xamarin.PropertyEditing.Mac NSLayoutConstraint.Create (this.errorMessages, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 1f, -10f), NSLayoutConstraint.Create (this.errorMessages, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1f, -40f), }); - - this.Appearance = PropertyEditorPanel.ThemeManager.CurrentAppearance; } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/GroupEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/GroupEditorControl.cs index 03f2662..8a1290e 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/GroupEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/GroupEditorControl.cs @@ -14,8 +14,13 @@ namespace Xamarin.PropertyEditing.Mac internal class GroupEditorControl : NSView, IEditorView { - public GroupEditorControl () + public GroupEditorControl (IHostResourceProvider hostResources) { + if (hostResources == null) + throw new ArgumentNullException (nameof (hostResources)); + + this.hostResources = hostResources; + this.container = new NSStackView (Bounds) { Alignment = NSLayoutAttribute.CenterX, AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable @@ -55,7 +60,7 @@ namespace Xamarin.PropertyEditing.Mac view = this.hostedEditor; } else { - view = this.selector.GetEditor (gvm.Properties[0]); + view = this.selector.GetEditor (this.hostResources, gvm.Properties[0]); } nint editorHeight = view.GetHeight (gvm.Properties[0]); @@ -87,6 +92,7 @@ namespace Xamarin.PropertyEditing.Mac private readonly NSStackView container; private readonly NSView host; private readonly PropertyGroupedEditorSelector selector = new PropertyGroupedEditorSelector (); + private readonly IHostResourceProvider hostResources; private IEditorView hostedEditor; private GroupedDataSource source; @@ -175,11 +181,11 @@ namespace Xamarin.PropertyEditing.Mac string identifier = pvm.GetType().FullName; PreviewView view = table.MakeView (identifier, table) as PreviewView; if (view == null) { - IValueView valueView = this.selector.CreateView (pvm.Property.Type); + IValueView valueView = this.selector.CreateView (this.host.hostResources, pvm.Property.Type); if (valueView == null) return new NSView (); - view = new PreviewView (valueView, new CGRect (0, 0, table.TableColumns ()[1].Width, table.RowHeight)) { + view = new PreviewView (this.host.hostResources, valueView, new CGRect (0, 0, table.TableColumns ()[1].Width, table.RowHeight)) { Identifier = identifier }; } @@ -192,7 +198,7 @@ namespace Xamarin.PropertyEditing.Mac private class PreviewView : NSView { - public PreviewView (IValueView valueView, CGRect frame) + public PreviewView (IHostResourceProvider hostResources, IValueView valueView, CGRect frame) { Frame = frame; @@ -201,7 +207,7 @@ namespace Xamarin.PropertyEditing.Mac valueView.NativeView.AutoresizingMask = NSViewResizingMask.WidthSizable; AddSubview (valueView.NativeView); - this.propertyButton = new PropertyButton { + this.propertyButton = new PropertyButton (hostResources) { Frame = new CGRect (valueView.NativeView.Frame.Width, 0, PropertyButton.DefaultSize, PropertyButton.DefaultSize), AutoresizingMask = NSViewResizingMask.MinXMargin }; @@ -249,7 +255,7 @@ namespace Xamarin.PropertyEditing.Mac PropertyViewModel pvm = ViewModel.Properties[(int)index]; if (this.hostedEditor == null) { - this.hostedEditor = this.selector.GetEditor (pvm); + this.hostedEditor = this.selector.GetEditor (this.hostResources, pvm); this.host.Frame = this.hostedEditor.NativeView.Bounds; this.hostedEditor.NativeView.AutoresizingMask = NSViewResizingMask.WidthSizable; this.host.AddSubview (this.hostedEditor.NativeView); diff --git a/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs index ee6e826..2511817 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs @@ -12,11 +12,12 @@ namespace Xamarin.PropertyEditing.Mac internal class NumericEditorControl<T> : PropertyEditorControl<NumericPropertyViewModel<T>> { - public NumericEditorControl () + public NumericEditorControl (IHostResourceProvider hostResources) + : base (hostResources) { base.TranslatesAutoresizingMaskIntoConstraints = false; - NumericEditor = new NumericSpinEditor<T> (); + NumericEditor = new NumericSpinEditor<T> (hostResources); NumericEditor.ValueChanged += OnValueChanged; var t = typeof (T); diff --git a/Xamarin.PropertyEditing.Mac/Controls/PanelHeaderEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/PanelHeaderEditorControl.cs index d1d9dfa..0c76c5d 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PanelHeaderEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PanelHeaderEditorControl.cs @@ -12,8 +12,13 @@ namespace Xamarin.PropertyEditing.Mac internal class PanelHeaderEditorControl : NSView { - public PanelHeaderEditorControl () + public PanelHeaderEditorControl (IHostResourceProvider hostResources) { + if (hostResources == null) + throw new ArgumentNullException (nameof (hostResources)); + + this.hostResources = hostResources; + NSControlSize controlSize = NSControlSize.Small; TranslatesAutoresizingMaskIntoConstraints = false; @@ -104,6 +109,8 @@ namespace Xamarin.PropertyEditing.Mac this.propertyObjectName.NextKeyView = nextKeyView; } + private readonly IHostResourceProvider hostResources; + private NSImageView propertyIcon; private NSTextField propertyObjectName; private UnfocusableTextField typeLabel, typeDisplay, objectNameLabel; diff --git a/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs index 9c56a89..75d2330 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs @@ -10,7 +10,8 @@ namespace Xamarin.PropertyEditing.Mac { internal abstract class PointEditorControl<T> : BasePointEditorControl<T> { - public PointEditorControl () + public PointEditorControl (IHostResourceProvider hostResources) + : base (hostResources) { XLabel.Frame = new CGRect (34, -5, 25, 22); XLabel.Font = NSFont.FromFontName (DefaultFontName, DefaultDescriptionLabelFontSize); // TODO: Washed-out color following specs @@ -31,8 +32,14 @@ namespace Xamarin.PropertyEditing.Mac } } - internal class SystemPointEditorControl : PointEditorControl<Point> + internal class SystemPointEditorControl + : PointEditorControl<Point> { + public SystemPointEditorControl (IHostResourceProvider hostResources) + : base (hostResources) + { + } + protected override void UpdateValue () { XEditor.Value = ViewModel.Value.X; @@ -42,6 +49,11 @@ namespace Xamarin.PropertyEditing.Mac internal class CommonPointEditorControl : PointEditorControl<CommonPoint> { + public CommonPointEditorControl (IHostResourceProvider hostResource) + : base (hostResource) + { + } + protected override void UpdateValue () { XEditor.Value = ViewModel.Value.X; diff --git a/Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs index 2a8fcd3..d2e8ae8 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs @@ -12,9 +12,11 @@ using Xamarin.PropertyEditing.Mac.Resources; namespace Xamarin.PropertyEditing.Mac { - internal class PredefinedValuesEditor<T> : PropertyEditorControl<PredefinedValuesViewModel<T>> + internal class PredefinedValuesEditor<T> + : PropertyEditorControl<PredefinedValuesViewModel<T>> { - public PredefinedValuesEditor () + public PredefinedValuesEditor (IHostResourceProvider hostResources) + : base (hostResources) { base.TranslatesAutoresizingMaskIntoConstraints = false; @@ -44,8 +46,6 @@ namespace Xamarin.PropertyEditing.Mac this.popUpButton.Activated += (o, e) => { ViewModel.ValueName = (o as NSPopUpButton).Title; }; - - UpdateTheme (); } public override NSView FirstKeyView => this.firstKeyView; diff --git a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs index 46bebb8..efa2171 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs @@ -10,6 +10,11 @@ namespace Xamarin.PropertyEditing.Mac internal abstract class PropertyEditorControl : BaseEditorControl, IEditorView { + protected PropertyEditorControl (IHostResourceProvider hostResources) + : base (hostResources) + { + } + public string Label { get; set; } public abstract NSView FirstKeyView { get; } @@ -126,9 +131,15 @@ namespace Xamarin.PropertyEditing.Mac protected abstract void UpdateAccessibilityValues (); } - internal abstract class PropertyEditorControl<TViewModel> : PropertyEditorControl + internal abstract class PropertyEditorControl<TViewModel> + : PropertyEditorControl where TViewModel : PropertyViewModel { + public PropertyEditorControl (IHostResourceProvider hostResources) + : base (hostResources) + { + } + internal new TViewModel ViewModel { get { return (TViewModel)base.ViewModel; } diff --git a/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs index fedf160..e49c907 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs @@ -11,11 +11,12 @@ namespace Xamarin.PropertyEditing.Mac { private RatioEditor<T> ratioEditor; - public RatioEditorControl () + public RatioEditorControl (IHostResourceProvider hostResources) + : base (hostResources) { base.TranslatesAutoresizingMaskIntoConstraints = false; - this.ratioEditor = new RatioEditor<T> { + this.ratioEditor = new RatioEditor<T> (hostResources) { AllowNegativeValues = false, AllowRatios = true, BackgroundColor = NSColor.Clear, @@ -36,8 +37,6 @@ namespace Xamarin.PropertyEditing.Mac NSLayoutConstraint.Create (this.ratioEditor, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 1f, -32f), NSLayoutConstraint.Create (this.ratioEditor, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, DefaultControlHeight), }); - - UpdateTheme (); } public override NSView FirstKeyView => ratioEditor.NumericEditor; diff --git a/Xamarin.PropertyEditing.Mac/Controls/RectangleEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/RectangleEditorControl.cs index 43a52e9..133b490 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/RectangleEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/RectangleEditorControl.cs @@ -7,9 +7,11 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - internal abstract class RectangleEditorControl<T>: BaseRectangleEditorControl<T> + internal abstract class RectangleEditorControl<T> + : BaseRectangleEditorControl<T> { - protected RectangleEditorControl () + protected RectangleEditorControl (IHostResourceProvider hostResources) + : base (hostResources) { // TODO localize XLabel.Frame = new CGRect (34, 28, 25, 22); @@ -43,8 +45,14 @@ namespace Xamarin.PropertyEditing.Mac } } - internal class SystemRectangleEditorControl : RectangleEditorControl<Rectangle> + internal class SystemRectangleEditorControl + : RectangleEditorControl<Rectangle> { + public SystemRectangleEditorControl (IHostResourceProvider hostResources) + : base (hostResources) + { + } + protected override void UpdateValue () { XEditor.Value = ViewModel.Value.X; @@ -54,8 +62,14 @@ namespace Xamarin.PropertyEditing.Mac } } - internal class CommonRectangleEditorControl : RectangleEditorControl<CommonRectangle> + internal class CommonRectangleEditorControl + : RectangleEditorControl<CommonRectangle> { + public CommonRectangleEditorControl (IHostResourceProvider hostResources) + : base (hostResources) + { + } + protected override void UpdateValue () { XEditor.Value = ViewModel.Value.X; diff --git a/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourcePanel.cs b/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourcePanel.cs index 4907d2a..2a3143b 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourcePanel.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourcePanel.cs @@ -18,7 +18,8 @@ namespace Xamarin.PropertyEditing.Mac private NSTableView resourceTable; private ResourceTableDataSource dataSource; - private ResourceSelectorViewModel viewModel; + private readonly ResourceSelectorViewModel viewModel; + public ResourceSelectorViewModel ViewModel => this.viewModel; private SimpleCollectionView collectionView => this.viewModel.Resources as SimpleCollectionView; public Resource SelectedResource { @@ -38,11 +39,14 @@ namespace Xamarin.PropertyEditing.Mac private object selectedValue; - public RequestResourcePanel (ResourceSelectorViewModel viewModel, object value) + public RequestResourcePanel (IHostResourceProvider hostResources, ResourceSelectorViewModel viewModel, object value) { + if (hostResources == null) + throw new ArgumentNullException (nameof (hostResources)); + this.viewModel = viewModel; this.viewModel.PropertyChanged += OnPropertyChanged; - Initialize (value); + Initialize (hostResources, value); } private void OnPropertyChanged (object sender, PropertyChangedEventArgs e) @@ -58,7 +62,7 @@ namespace Xamarin.PropertyEditing.Mac } } - private void Initialize (object selectedValue) + private void Initialize (IHostResourceProvider hostResources, object selectedValue) { this.selectedValue = selectedValue; Frame = new CGRect (10, 35, 630, 305); @@ -80,7 +84,7 @@ namespace Xamarin.PropertyEditing.Mac }; this.dataSource = new ResourceTableDataSource (viewModel); - var resourceTableDelegate = new ResourceTableDelegate (dataSource); + var resourceTableDelegate = new ResourceTableDelegate (hostResources, dataSource); resourceTableDelegate.ResourceSelected += (sender, e) => { this.previewPanel.SelectedResource = SelectedResource; diff --git a/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourceView.cs b/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourceView.cs index 8a85e1d..f810428 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourceView.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourceView.cs @@ -19,7 +19,8 @@ namespace Xamarin.PropertyEditing.Mac } } - internal class RequestResourceView : BasePopOverViewModelControl + internal class RequestResourceView + : BasePopOverViewModelControl { NSSearchField searchResources; NSSegmentedControl segmentedControl; @@ -43,7 +44,8 @@ namespace Xamarin.PropertyEditing.Mac } } - public RequestResourceView (PropertyViewModel propertyViewModel) : base (propertyViewModel, Properties.Resources.SelectResourceTitle, "resource-editor-32") + public RequestResourceView (IHostResourceProvider hostResources, PropertyViewModel propertyViewModel) + : base (hostResources, propertyViewModel, Properties.Resources.SelectResourceTitle, "resource-editor-32") { Initialize (propertyViewModel); } @@ -77,9 +79,9 @@ namespace Xamarin.PropertyEditing.Mac var resourceSelector = resourceSelectorPropertyInfo.GetValue (propertyViewModel) as ResourceSelectorViewModel; if (resourceSelector != null) { - this.resourceSelectorPanel = new RequestResourcePanel (resourceSelector, resourceValue); + this.resourceSelectorPanel = new RequestResourcePanel (HostResources, resourceSelector, resourceValue); } else { - this.resourceSelectorPanel = new RequestResourcePanel (new ResourceSelectorViewModel (propertyViewModel.TargetPlatform.ResourceProvider, propertyViewModel.Editors.Select (ed => ed.Target), propertyViewModel.Property), resourceValue); + this.resourceSelectorPanel = new RequestResourcePanel (HostResources, new ResourceSelectorViewModel (propertyViewModel.TargetPlatform.ResourceProvider, propertyViewModel.Editors.Select (ed => ed.Target), propertyViewModel.Property), resourceValue); } this.resourceSelectorPanel.ResourceSelected += (sender, e) => { propertyViewModel.Resource = this.resourceSelectorPanel.SelectedResource; @@ -95,21 +97,21 @@ namespace Xamarin.PropertyEditing.Mac switch (this.segmentedControl.SelectedSegment) { case 0: this.resourceSelectorPanel.ViewModel.ShowBothResourceTypes = true; - this.segmentedControl.SetImage (PropertyEditorPanel.ThemeManager.GetImageForTheme ("resource-editor-16"), 2); + this.segmentedControl.SetImage (HostResources.GetNamedImage ("resource-editor-16"), 2); break; case 1: this.resourceSelectorPanel.ViewModel.ShowOnlyLocalResources = true; - this.segmentedControl.SetImage (PropertyEditorPanel.ThemeManager.GetImageForTheme ("resource-editor-16"), 2); + this.segmentedControl.SetImage (HostResources.GetNamedImage ("resource-editor-16"), 2); break; case 2: this.resourceSelectorPanel.ViewModel.ShowOnlySystemResources = true; - this.segmentedControl.SetImage (PropertyEditorPanel.ThemeManager.GetImageForTheme ("resource-editor-16", true), 2); + this.segmentedControl.SetImage (HostResources.GetNamedImage ("resource-editor-16~sel"), 2); break; } this.resourceSelectorPanel.ReloadData (); }); - this.segmentedControl.SetImage (PropertyEditorPanel.ThemeManager.GetImageForTheme ("resource-editor-16"), 2); + this.segmentedControl.SetImage (HostResources.GetNamedImage ("resource-editor-16"), 2); this.segmentedControl.Frame = new CGRect ((FrameWidthThird - (segmentedControl.Bounds.Width) / 2), 5, (Frame.Width - (FrameWidthThird)) - 10, 24); this.segmentedControl.Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize); this.segmentedControl.TranslatesAutoresizingMaskIntoConstraints = false; @@ -133,8 +135,6 @@ namespace Xamarin.PropertyEditing.Mac AddSubview (this.showPreviewImage); - this.Appearance = PropertyEditorPanel.ThemeManager.CurrentAppearance; - OnSearchResourcesChanged(null, null); RepositionControls (); diff --git a/Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs b/Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs index 9ea3a19..b712edf 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs @@ -10,8 +10,6 @@ namespace Xamarin.PropertyEditing.Mac internal class ResourceTableDelegate : NSTableViewDelegate { - private ResourceTableDataSource datasource; - const string iconIdentifier = "icon"; const string typeIdentifier = "type"; const string nameIdentifier = "name"; @@ -19,11 +17,13 @@ namespace Xamarin.PropertyEditing.Mac public event EventHandler ResourceSelected; - private nint previousRow = -1; - - public ResourceTableDelegate (ResourceTableDataSource resourceTableDatasource) + public ResourceTableDelegate (IHostResourceProvider hostResources, ResourceTableDataSource resourceTableDatasource) { + if (hostResources == null) + throw new ArgumentNullException (nameof (hostResources)); + this.datasource = resourceTableDatasource; + this.hostResources = hostResources; } // the table is looking for this method, picks it up automagically @@ -38,7 +38,7 @@ namespace Xamarin.PropertyEditing.Mac var iconView = (NSImageView)tableView.MakeView (iconIdentifier, this); if (iconView == null) { iconView = new NSImageView { - Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("resource-editor-32"), + Image = this.hostResources.GetNamedImage ("resource-editor-32"), ImageScaling = NSImageScale.None, Identifier = iconIdentifier, }; @@ -95,18 +95,22 @@ namespace Xamarin.PropertyEditing.Mac if (previousRow != -1 && previousRow < tableView.RowCount && tableView.GetView (0, previousRow, false) is NSImageView previousIconColumn) { - previousIconColumn.Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("resource-editor-32"); + previousIconColumn.Image = this.hostResources.GetNamedImage ("resource-editor-32"); } if (tableView.SelectedRow != -1 && tableView.GetView (0, tableView.SelectedRow, false) is NSImageView selectedIconColumn) { - selectedIconColumn.Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("resource-editor-32", true); + selectedIconColumn.Image = this.hostResources.GetNamedImage ("resource-editor-32~sel"); previousRow = tableView.SelectedRow; } } ResourceSelected?.Invoke (this, EventArgs.Empty); } + private readonly IHostResourceProvider hostResources; + private readonly ResourceTableDataSource datasource; + private nint previousRow = -1; + private NSView MakeValueView (Resource resource, NSTableView tableView) { var view = (NSView)tableView.MakeView (valueIdentifier, this); @@ -123,7 +127,7 @@ namespace Xamarin.PropertyEditing.Mac return view; } - NSView GetValueView (Type representationType) + private NSView GetValueView (Type representationType) { Type[] genericArgs = null; Type valueRenderType; diff --git a/Xamarin.PropertyEditing.Mac/Controls/SizeEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/SizeEditorControl.cs index 66120f4..f27923b 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/SizeEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/SizeEditorControl.cs @@ -11,7 +11,8 @@ namespace Xamarin.PropertyEditing.Mac internal abstract class SizeEditorControl<T> : BasePointEditorControl<T> where T : struct { - public SizeEditorControl () + public SizeEditorControl (IHostResourceProvider hostResource) + : base (hostResource) { XLabel.Frame = new CGRect (20, -5, 50, 22); XLabel.Font = NSFont.FromFontName (DefaultFontName, DefaultDescriptionLabelFontSize); // TODO: Washed-out color following specs @@ -38,8 +39,14 @@ namespace Xamarin.PropertyEditing.Mac } } - internal class SystemSizeEditorControl : SizeEditorControl<Size> + internal class SystemSizeEditorControl + : SizeEditorControl<Size> { + public SystemSizeEditorControl (IHostResourceProvider hostResources) + : base (hostResources) + { + } + protected override void UpdateValue () { XEditor.Value = ViewModel.Value.Width; @@ -47,8 +54,14 @@ namespace Xamarin.PropertyEditing.Mac } } - internal class CommonSizeEditorControl : SizeEditorControl<CommonSize> + internal class CommonSizeEditorControl + : SizeEditorControl<CommonSize> { + public CommonSizeEditorControl (IHostResourceProvider hostResources) + : base (hostResources) + { + } + protected override void UpdateValue () { XEditor.Value = ViewModel.Value.Width; diff --git a/Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs index 3992972..75f46d4 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs @@ -11,7 +11,8 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - internal class StringEditorControl : PropertyEditorControl<PropertyViewModel<string>> + internal class StringEditorControl + : PropertyEditorControl<PropertyViewModel<string>> { private NSTextField stringEditor { get; set; } @@ -23,7 +24,8 @@ namespace Xamarin.PropertyEditing.Mac internal NSPopUpButton inputModePopup; private IReadOnlyList<InputMode> viewModelInputModes; - public StringEditorControl () + public StringEditorControl (IHostResourceProvider hostResource) + : base (hostResource) { this.stringEditor = new NSTextField { BackgroundColor = NSColor.Clear, @@ -46,8 +48,6 @@ namespace Xamarin.PropertyEditing.Mac this.stringEditorWidthConstraint, NSLayoutConstraint.Create (this.stringEditor, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, DefaultControlHeight - 3), }); - - UpdateTheme (); } protected override void UpdateValue () diff --git a/Xamarin.PropertyEditing.Mac/Controls/ThicknessEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/ThicknessEditorControl.cs index 50fed48..2f9dd17 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/ThicknessEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/ThicknessEditorControl.cs @@ -7,9 +7,11 @@ using Xamarin.PropertyEditing.ViewModels; namespace Xamarin.PropertyEditing.Mac { - internal class CommonThicknessEditorControl : BaseRectangleEditorControl<CommonThickness> + internal class CommonThicknessEditorControl + : BaseRectangleEditorControl<CommonThickness> { - public CommonThicknessEditorControl () + public CommonThicknessEditorControl (IHostResourceProvider hostResources) + : base (hostResources) { XLabel.Frame = new CGRect (28, 28, 50, 22); XLabel.Font = NSFont.FromFontName (DefaultFontName, DefaultDescriptionLabelFontSize); |