diff options
author | Eric Maupin <ermaup@microsoft.com> | 2019-02-19 23:35:15 +0300 |
---|---|---|
committer | Eric Maupin <ermaup@microsoft.com> | 2019-03-13 01:32:59 +0300 |
commit | f21098848ccae7890012106d51f70ef8476744a4 (patch) | |
tree | 9e4683fec081d1f39faaa329ad98ce900e846567 /Xamarin.PropertyEditing.Mac/Controls/Custom | |
parent | e61f6717dd084a4dc88feedf0a96f0ac6fabf6fe (diff) |
[mac] Collection property editor
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls/Custom')
3 files changed, 90 insertions, 65 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicBox.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicBox.cs new file mode 100644 index 0000000..a3483a1 --- /dev/null +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicBox.cs @@ -0,0 +1,87 @@ +using System; +using AppKit; + +namespace Xamarin.PropertyEditing.Mac +{ + internal class DynamicBox + : NSBox + { + public DynamicBox (IHostResourceProvider hostResources, string fillName = null, string borderName = null) + { + if (hostResources == null) + throw new ArgumentNullException (nameof (hostResources)); + + BorderWidth = 0; + BoxType = NSBoxType.NSBoxCustom; + TranslatesAutoresizingMaskIntoConstraints = false; + + this.fillColor = fillName; + if (fillName == null) + FillColor = NSColor.Clear; + + this.borderColor = borderName; + if (borderName == null) + BorderColor = NSColor.Clear; + + HostResourceProvider = hostResources; + } + + public IHostResourceProvider HostResourceProvider + { + get { return this.hostResources; } + set + { + this.hostResources = value; + ViewDidChangeEffectiveAppearance (); + } + } + + public string FillColorName + { + get => this.fillColor; + set + { + this.fillColor = value; + if (value == null) + FillColor = NSColor.Clear; + + ViewDidChangeEffectiveAppearance (); + } + } + + public string BorderColorName + { + get => this.borderColor; + set + { + this.borderColor = value; + if (value == null) + BorderColor = NSColor.Clear; + + ViewDidChangeEffectiveAppearance (); + } + } + + public override void ViewDidChangeEffectiveAppearance () + { + if (this.fillColor != null) { + NSColor color = this.hostResources.GetNamedColor (this.fillColor); + if (color == null) + return; + + FillColor = color; + } + + if (this.borderColor != null) { + NSColor color = this.hostResources.GetNamedColor (this.borderColor); + if (color == null) + return; + + BorderColor = color; + } + } + + private IHostResourceProvider hostResources; + private string fillColor, borderColor; + } +} diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicFillBox.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicFillBox.cs deleted file mode 100644 index a542b5d..0000000 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicFillBox.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using AppKit; - -namespace Xamarin.PropertyEditing.Mac -{ - internal class DynamicFillBox - : NSBox - { - public DynamicFillBox (IHostResourceProvider hostResources, string colorName) - { - if (hostResources == null) - throw new ArgumentNullException (nameof (hostResources)); - - BorderWidth = 0; - BoxType = NSBoxType.NSBoxCustom; - TranslatesAutoresizingMaskIntoConstraints = false; - this.colorName = colorName; - if (colorName == null) - FillColor = NSColor.Clear; - - HostResourceProvider = hostResources; - } - - public IHostResourceProvider HostResourceProvider - { - get { return this.hostResources; } - set - { - this.hostResources = value; - ViewDidChangeEffectiveAppearance (); - } - } - - public string FillColorName - { - get => this.colorName; - set - { - this.colorName = value; - if (value == null) - FillColor = NSColor.Clear; - - ViewDidChangeEffectiveAppearance (); - } - } - - public override void ViewDidChangeEffectiveAppearance () - { - if (this.colorName == null) - return; - - NSColor color = this.hostResources.GetNamedColor (this.colorName); - if (color == null) - return; - - FillColor = color; - } - - private IHostResourceProvider hostResources; - private string colorName; - } -} diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs index fa2e4d9..4911171 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs @@ -104,7 +104,7 @@ namespace Xamarin.PropertyEditing.Mac NSView tabs = this.tabStack; if (TabBackgroundColor != null) { - this.tabContainer = new DynamicFillBox (HostResources, TabBackgroundColor) { + this.tabContainer = new DynamicBox (HostResources, TabBackgroundColor) { ContentView = this.tabStack }; @@ -114,7 +114,7 @@ namespace Xamarin.PropertyEditing.Mac this.innerStack.AddView (tabs, NSStackViewGravity.Top); if (TabBorderColor != null) {
- this.border = new DynamicFillBox (HostResources, TabBorderColor) { + this.border = new DynamicBox (HostResources, TabBorderColor) { Frame = new CGRect (0, 0, 1, 1), AutoresizingMask = NSViewResizingMask.WidthSizable }; @@ -144,7 +144,7 @@ namespace Xamarin.PropertyEditing.Mac private string tabBackground, tabBorder;
private IUnderliningTabView selected; - private DynamicFillBox tabContainer, border;
+ private DynamicBox tabContainer, border;
private NSStackView innerStack;
private readonly NSStackView tabStack = new NSStackView () {
Spacing = 1f,
|