Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Maupin <ermaup@microsoft.com>2019-01-18 20:31:01 +0300
committerEric Maupin <ermaup@microsoft.com>2019-01-18 20:31:01 +0300
commita0fc91b672ce4510c4462116af223287f5ff8fa6 (patch)
tree1707c5ae79842d72d1535407798ac1ffad01c4eb /Xamarin.PropertyEditing.Mac
parentbbc4132eb17bf3fdbb27ba6a19d012c41b03cb29 (diff)
[mac] Breakout DynamicFill into reusable
Diffstat (limited to 'Xamarin.PropertyEditing.Mac')
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/DynamicFillBox.cs46
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs49
-rw-r--r--Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj1
3 files changed, 50 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)
diff --git a/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj b/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj
index ac84da4..42b5ee1 100644
--- a/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj
+++ b/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj
@@ -142,6 +142,7 @@
<Compile Include="Controls\Layout.cs" />
<Compile Include="IHostResourceProvider.cs" />
<Compile Include="HostResourceProvider.cs" />
+ <Compile Include="Controls\Custom\DynamicFillBox.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controls\" />