diff options
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls/Custom')
-rw-r--r-- | Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicFillBox.cs | 46 | ||||
-rw-r--r-- | Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs | 49 |
2 files changed, 49 insertions, 46 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicFillBox.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicFillBox.cs new file mode 100644 index 0000000..800d1c2 --- /dev/null +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicFillBox.cs @@ -0,0 +1,46 @@ +using System; +using AppKit; + +namespace Xamarin.PropertyEditing.Mac +{ + internal class DynamicFillBox + : NSBox + { + public DynamicFillBox (IHostResourceProvider hostResources, string colorName) + { + this.hostResources = hostResources; + BorderWidth = 0; + BoxType = NSBoxType.NSBoxCustom; + TranslatesAutoresizingMaskIntoConstraints = false; + this.colorName = colorName; + if (colorName == null) + FillColor = NSColor.Clear; + + 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; + + FillColor = this.hostResources.GetNamedColor (this.colorName); + } + + private readonly IHostResourceProvider hostResources; + private string colorName; + } +} diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs index b760e22..cdd275b 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 DynamicFill (HostResources, TabBackgroundColor) { + this.tabContainer = new DynamicFillBox (HostResources, TabBackgroundColor) { ContentView = this.tabStack }; @@ -114,10 +114,8 @@ namespace Xamarin.PropertyEditing.Mac this.innerStack.AddView (tabs, NSStackViewGravity.Top); if (TabBorderColor != null) {
- this.border = new DynamicFill (HostResources, TabBorderColor) { + this.border = new DynamicFillBox (HostResources, TabBorderColor) { Frame = new CGRect (0, 0, 1, 1), - BorderWidth = 0, - BoxType = NSBoxType.NSBoxCustom, AutoresizingMask = NSViewResizingMask.WidthSizable }; @@ -146,7 +144,7 @@ namespace Xamarin.PropertyEditing.Mac private string tabBackground, tabBorder;
private IUnderliningTabView selected; - private DynamicFill tabContainer, border;
+ private DynamicFillBox tabContainer, border;
private NSStackView innerStack;
private NSStackView tabStack = new NSStackView () {
Spacing = 10f,
@@ -156,47 +154,6 @@ namespace Xamarin.PropertyEditing.Mac private NSEdgeInsets edgeInsets = new NSEdgeInsets (0, 0, 0, 0);
- private class DynamicFill
- : NSBox - {
- public DynamicFill (IHostResourceProvider hostResources, string colorName) - { - this.hostResources = hostResources;
- BorderWidth = 0;
- BoxType = NSBoxType.NSBoxCustom;
- TranslatesAutoresizingMaskIntoConstraints = false; - this.colorName = colorName; - if (colorName == null) - FillColor = NSColor.Clear; - - 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; - - FillColor = this.hostResources.GetNamedColor (this.colorName); - }
-
- private readonly IHostResourceProvider hostResources; - private string colorName; - }
-
private void UpdatePadding() { if (this.innerStack == null) |