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-03 22:44:37 +0300
committerEric Maupin <ermaup@microsoft.com>2019-01-11 23:19:25 +0300
commit71ad75860e1c5b6c33163d390988dbfbf409b4ac (patch)
tree80f6ed1ac0a1a0face888e3481f802f4d328a312
parent104acbcc9c62e1a90e9e43cb7630583cb2b49ca4 (diff)
[mac] Revamp theming
This commit: - Drops outdated CG* editors - Drops ThemeManager - Introduces IHostResourceProvider - Moves all images to new API - Starts implementing colors
-rw-r--r--.gitignore1
-rw-r--r--Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/Checkerboard0.colorset/Contents.json38
-rw-r--r--Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/Checkerboard1.colorset/Contents.json38
-rw-r--r--Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/Contents.json2
-rw-r--r--Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/DescriptionLabelColor.colorset/Contents.json14
-rw-r--r--Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/ForegroundColor.colorset/Contents.json14
-rw-r--r--Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/PadBackgroundColor.colorset/Contents.json38
-rw-r--r--Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/PopoverContentBackground.colorset/Contents.json38
-rw-r--r--Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/SelectionBackgroundColor.colorset/Contents.json20
-rw-r--r--Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/SelectionUnfocusedBackgroundColor.colorset/Contents.json38
-rw-r--r--Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/ValueBlockBackgroundColor.colorset/Contents.json38
-rw-r--r--Xamarin.PropertyEditing.Mac.Standalone/Main.storyboard4
-rw-r--r--Xamarin.PropertyEditing.Mac.Standalone/ViewController.cs15
-rw-r--r--Xamarin.PropertyEditing.Mac.Standalone/Xamarin.PropertyEditing.Mac.Standalone.csproj9
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/BaseEditorControl.cs37
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/BasePointEditorControl.cs15
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/BaseRectangleEditorControl.cs23
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/BooleanEditorControl.cs8
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/BrushEditorControl.cs15
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/CGPointEditorControl.cs26
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/CGRectEditorControl.cs22
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/CGSizeEditorControl.cs26
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/CombinablePropertyEditor.cs5
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverControl.cs14
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/BasePopOverViewModelControl.cs3
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs9
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentEditor.cs53
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentTabViewController.cs8
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/ColorComponentViewController.cs16
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushLayer.cs20
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/CommonBrushView.cs19
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/ComponentSpinEditor.cs6
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/DrawingExtensions.cs24
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/HistoryLayer.cs15
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialBrushEditorViewController.cs39
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/NumericSpinEditor.cs61
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs40
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/RatioEditor.cs3
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushPropertyViewDelegate.cs8
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceBrushViewController.cs10
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/ResourceOutlineViewDelegate.cs19
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditor.cs30
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/SolidColorBrushEditorViewController.cs16
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs55
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTabViewController.cs15
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/UnderlinedTextField.cs27
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableButton.cs19
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/Custom/UnfocusableTextField.cs26
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/CustomExpressionView.cs3
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/EditorContainer.cs7
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/ErrorMessageView.cs6
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/GroupEditorControl.cs20
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs5
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/PanelHeaderEditorControl.cs9
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/PointEditorControl.cs16
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/PredefinedValuesEditor.cs8
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs13
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/RatioEditorControl.cs7
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/RectangleEditorControl.cs22
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourcePanel.cs14
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourceView.cs20
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs22
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/SizeEditorControl.cs19
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs8
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/ThicknessEditorControl.cs6
-rw-r--r--Xamarin.PropertyEditing.Mac/HostResourceProvider.cs34
-rw-r--r--Xamarin.PropertyEditing.Mac/IHostResourceProvider.cs12
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs53
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyEditorSelector.cs10
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyGroupedEditorSelector.cs9
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyInlinePreviewSelector.cs6
-rw-r--r--Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs19
-rw-r--r--Xamarin.PropertyEditing.Mac/Themes/MacThemeManager.cs51
-rw-r--r--Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj7
-rw-r--r--Xamarin.PropertyEditing/Themes/BaseThemeManager.cs38
-rw-r--r--Xamarin.PropertyEditing/Themes/PropertyEditorTheme.cs9
-rw-r--r--Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj4
77 files changed, 873 insertions, 623 deletions
diff --git a/.gitignore b/.gitignore
index 6210b99..bc95dc0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@ obj
/out
.vs
packages
+.DS_Store
diff --git a/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/Checkerboard0.colorset/Contents.json b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/Checkerboard0.colorset/Contents.json
new file mode 100644
index 0000000..a0724b3
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/Checkerboard0.colorset/Contents.json
@@ -0,0 +1,38 @@
+{
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ },
+ "colors" : [
+ {
+ "idiom" : "universal",
+ "color" : {
+ "color-space" : "srgb",
+ "components" : {
+ "red" : "0xFF",
+ "alpha" : "1.000",
+ "blue" : "0xFF",
+ "green" : "0xFF"
+ }
+ }
+ },
+ {
+ "idiom" : "universal",
+ "appearances" : [
+ {
+ "appearance" : "luminosity",
+ "value" : "dark"
+ }
+ ],
+ "color" : {
+ "color-space" : "srgb",
+ "components" : {
+ "red" : "0.149",
+ "alpha" : "1.000",
+ "blue" : "0.149",
+ "green" : "0.149"
+ }
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/Checkerboard1.colorset/Contents.json b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/Checkerboard1.colorset/Contents.json
new file mode 100644
index 0000000..954a6bf
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/Checkerboard1.colorset/Contents.json
@@ -0,0 +1,38 @@
+{
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ },
+ "colors" : [
+ {
+ "idiom" : "universal",
+ "color" : {
+ "color-space" : "srgb",
+ "components" : {
+ "red" : "0xD9",
+ "alpha" : "1.000",
+ "blue" : "0xD9",
+ "green" : "0xD9"
+ }
+ }
+ },
+ {
+ "idiom" : "universal",
+ "appearances" : [
+ {
+ "appearance" : "luminosity",
+ "value" : "dark"
+ }
+ ],
+ "color" : {
+ "color-space" : "srgb",
+ "components" : {
+ "red" : "0x00",
+ "alpha" : "1.000",
+ "blue" : "0x00",
+ "green" : "0x00"
+ }
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/Contents.json b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/Contents.json
index 4caf392..da4a164 100644
--- a/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/Contents.json
+++ b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/Contents.json
@@ -1,4 +1,4 @@
-{
+{
"info" : {
"version" : 1,
"author" : "xcode"
diff --git a/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/DescriptionLabelColor.colorset/Contents.json b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/DescriptionLabelColor.colorset/Contents.json
new file mode 100644
index 0000000..48a0385
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/DescriptionLabelColor.colorset/Contents.json
@@ -0,0 +1,14 @@
+{
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ },
+ "colors" : [
+ {
+ "idiom" : "universal",
+ "color" : {
+ "reference" : "secondaryLabelColor"
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/ForegroundColor.colorset/Contents.json b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/ForegroundColor.colorset/Contents.json
new file mode 100644
index 0000000..a673516
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/ForegroundColor.colorset/Contents.json
@@ -0,0 +1,14 @@
+{
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ },
+ "colors" : [
+ {
+ "idiom" : "universal",
+ "color" : {
+ "reference" : "labelColor"
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/PadBackgroundColor.colorset/Contents.json b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/PadBackgroundColor.colorset/Contents.json
new file mode 100644
index 0000000..70d3b65
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/PadBackgroundColor.colorset/Contents.json
@@ -0,0 +1,38 @@
+{
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ },
+ "colors" : [
+ {
+ "idiom" : "universal",
+ "color" : {
+ "color-space" : "srgb",
+ "components" : {
+ "red" : "0xF0",
+ "alpha" : "1.000",
+ "blue" : "0xF3",
+ "green" : "0xF1"
+ }
+ }
+ },
+ {
+ "idiom" : "universal",
+ "appearances" : [
+ {
+ "appearance" : "luminosity",
+ "value" : "dark"
+ }
+ ],
+ "color" : {
+ "color-space" : "srgb",
+ "components" : {
+ "red" : "0x26",
+ "alpha" : "1.000",
+ "blue" : "0x26",
+ "green" : "0x26"
+ }
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/PopoverContentBackground.colorset/Contents.json b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/PopoverContentBackground.colorset/Contents.json
new file mode 100644
index 0000000..028eb81
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/PopoverContentBackground.colorset/Contents.json
@@ -0,0 +1,38 @@
+{
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ },
+ "colors" : [
+ {
+ "idiom" : "universal",
+ "color" : {
+ "color-space" : "srgb",
+ "components" : {
+ "red" : "0xFF",
+ "alpha" : "1.000",
+ "blue" : "0xFF",
+ "green" : "0xFF"
+ }
+ }
+ },
+ {
+ "idiom" : "universal",
+ "appearances" : [
+ {
+ "appearance" : "luminosity",
+ "value" : "dark"
+ }
+ ],
+ "color" : {
+ "color-space" : "srgb",
+ "components" : {
+ "red" : "0x3D",
+ "alpha" : "1.000",
+ "blue" : "0x3D",
+ "green" : "0x3D"
+ }
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/SelectionBackgroundColor.colorset/Contents.json b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/SelectionBackgroundColor.colorset/Contents.json
new file mode 100644
index 0000000..01ee64f
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/SelectionBackgroundColor.colorset/Contents.json
@@ -0,0 +1,20 @@
+{
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ },
+ "colors" : [
+ {
+ "idiom" : "universal",
+ "color" : {
+ "color-space" : "srgb",
+ "components" : {
+ "red" : "0x51",
+ "alpha" : "1.000",
+ "blue" : "0xED",
+ "green" : "0x89"
+ }
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/SelectionUnfocusedBackgroundColor.colorset/Contents.json b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/SelectionUnfocusedBackgroundColor.colorset/Contents.json
new file mode 100644
index 0000000..0570f77
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/SelectionUnfocusedBackgroundColor.colorset/Contents.json
@@ -0,0 +1,38 @@
+{
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ },
+ "colors" : [
+ {
+ "idiom" : "universal",
+ "color" : {
+ "color-space" : "srgb",
+ "components" : {
+ "red" : "0xD8",
+ "alpha" : "1.000",
+ "blue" : "0xF3",
+ "green" : "0xE2"
+ }
+ }
+ },
+ {
+ "idiom" : "universal",
+ "appearances" : [
+ {
+ "appearance" : "luminosity",
+ "value" : "dark"
+ }
+ ],
+ "color" : {
+ "color-space" : "srgb",
+ "components" : {
+ "red" : "0x3F",
+ "alpha" : "1.000",
+ "blue" : "0x5E",
+ "green" : "0x4A"
+ }
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/ValueBlockBackgroundColor.colorset/Contents.json b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/ValueBlockBackgroundColor.colorset/Contents.json
new file mode 100644
index 0000000..7052754
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac.Standalone/Assets.xcassets/ValueBlockBackgroundColor.colorset/Contents.json
@@ -0,0 +1,38 @@
+{
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ },
+ "colors" : [
+ {
+ "idiom" : "universal",
+ "color" : {
+ "color-space" : "srgb",
+ "components" : {
+ "red" : "0.000",
+ "alpha" : "0.080",
+ "blue" : "0.000",
+ "green" : "0.000"
+ }
+ }
+ },
+ {
+ "idiom" : "universal",
+ "appearances" : [
+ {
+ "appearance" : "luminosity",
+ "value" : "dark"
+ }
+ ],
+ "color" : {
+ "color-space" : "srgb",
+ "components" : {
+ "red" : "1.000",
+ "alpha" : "0.100",
+ "blue" : "1.000",
+ "green" : "1.000"
+ }
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/Xamarin.PropertyEditing.Mac.Standalone/Main.storyboard b/Xamarin.PropertyEditing.Mac.Standalone/Main.storyboard
index fe8e29a..c5bfe6c 100644
--- a/Xamarin.PropertyEditing.Mac.Standalone/Main.storyboard
+++ b/Xamarin.PropertyEditing.Mac.Standalone/Main.storyboard
@@ -720,8 +720,8 @@
<segmentedCell key="cell" borderStyle="border" alignment="left" style="rounded" trackingMode="selectOne" id="qr0-t0-q16">
<font key="font" metaFont="system"/>
<segments>
- <segment label="Dark" width="61" selected="YES"/>
- <segment label="Light" width="61" tag="1"/>
+ <segment label="Dark" width="61"/>
+ <segment label="Light" width="61" selected="YES" tag="1"/>
<segment label="None"/>
</segments>
</segmentedCell>
diff --git a/Xamarin.PropertyEditing.Mac.Standalone/ViewController.cs b/Xamarin.PropertyEditing.Mac.Standalone/ViewController.cs
index 7a269f4..3b79ef7 100644
--- a/Xamarin.PropertyEditing.Mac.Standalone/ViewController.cs
+++ b/Xamarin.PropertyEditing.Mac.Standalone/ViewController.cs
@@ -83,18 +83,9 @@ namespace Xamarin.PropertyEditing.Mac.Standalone
// If theme toggled, then notify our manager
partial void OnThemeChanged (NSObject sender)
{
- var themeControl = sender as NSSegmentedControl;
- switch (themeControl.SelectedSegment) {
- case 0:
- PropertyEditorPanel.ThemeManager.Theme = Themes.PropertyEditorTheme.Dark;
- break;
- case 1:
- PropertyEditorPanel.ThemeManager.Theme = Themes.PropertyEditorTheme.Light;
- break;
- case 2:
- PropertyEditorPanel.ThemeManager.Theme = Themes.PropertyEditorTheme.None;
- break;
- }
+ var themeControl = (NSSegmentedControl)sender;
+
+ View.Appearance = NSAppearance.GetAppearance ((themeControl.SelectedSegment == 0) ? NSAppearance.NameVibrantDark : NSAppearance.NameAqua);
}
}
}
diff --git a/Xamarin.PropertyEditing.Mac.Standalone/Xamarin.PropertyEditing.Mac.Standalone.csproj b/Xamarin.PropertyEditing.Mac.Standalone/Xamarin.PropertyEditing.Mac.Standalone.csproj
index 654928c..df6d05f 100644
--- a/Xamarin.PropertyEditing.Mac.Standalone/Xamarin.PropertyEditing.Mac.Standalone.csproj
+++ b/Xamarin.PropertyEditing.Mac.Standalone/Xamarin.PropertyEditing.Mac.Standalone.csproj
@@ -68,6 +68,15 @@
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-512.png" />
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-512%402x.png" />
<ImageAsset Include="Assets.xcassets\Contents.json" />
+ <ImageAsset Include="Assets.xcassets\Checkerboard0.colorset\Contents.json" />
+ <ImageAsset Include="Assets.xcassets\Checkerboard1.colorset\Contents.json" />
+ <ImageAsset Include="Assets.xcassets\ForegroundColor.colorset\Contents.json" />
+ <ImageAsset Include="Assets.xcassets\PadBackgroundColor.colorset\Contents.json" />
+ <ImageAsset Include="Assets.xcassets\PopoverContentBackground.colorset\Contents.json" />
+ <ImageAsset Include="Assets.xcassets\SelectionBackgroundColor.colorset\Contents.json" />
+ <ImageAsset Include="Assets.xcassets\SelectionUnfocusedBackgroundColor.colorset\Contents.json" />
+ <ImageAsset Include="Assets.xcassets\ValueBlockBackgroundColor.colorset\Contents.json" />
+ <ImageAsset Include="Assets.xcassets\DescriptionLabelColor.colorset\Contents.json" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
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);
diff --git a/Xamarin.PropertyEditing.Mac/HostResourceProvider.cs b/Xamarin.PropertyEditing.Mac/HostResourceProvider.cs
new file mode 100644
index 0000000..b97f32a
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/HostResourceProvider.cs
@@ -0,0 +1,34 @@
+using System;
+using AppKit;
+using Foundation;
+
+namespace Xamarin.PropertyEditing.Mac
+{
+ public class HostResourceProvider
+ : IHostResourceProvider
+ {
+ public virtual NSColor GetNamedColor (string name)
+ {
+ return NSColor.FromName (name);
+ }
+
+ public virtual NSImage GetNamedImage (string name)
+ {
+ return NSImage.ImageNamed (name);
+ }
+
+ public virtual NSFont GetNamedFont (string name, nfloat fontSize)
+ {
+ return NSFont.FromFontName (name, fontSize);
+ }
+ }
+
+ public static class NamedResources
+ {
+ public const string Checkerboard0Color = "Checkerboard0";
+ public const string Checkerboard1Color = "Checkerboard1";
+ public const string ForegroundColor = "ForegroundColor";
+ public const string PadBackgroundColor = "PadBackgroundColor";
+ public const string DescriptionLabelColor = "DescriptionLabelColor";
+ }
+}
diff --git a/Xamarin.PropertyEditing.Mac/IHostResourceProvider.cs b/Xamarin.PropertyEditing.Mac/IHostResourceProvider.cs
new file mode 100644
index 0000000..46e7040
--- /dev/null
+++ b/Xamarin.PropertyEditing.Mac/IHostResourceProvider.cs
@@ -0,0 +1,12 @@
+using System;
+using AppKit;
+
+namespace Xamarin.PropertyEditing.Mac
+{
+ public interface IHostResourceProvider
+ {
+ NSColor GetNamedColor (string name);
+ NSImage GetNamedImage (string name);
+ NSFont GetNamedFont (string name, nfloat fontSize);
+ }
+}
diff --git a/Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs b/Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs
index 1d3c965..0979c87 100644
--- a/Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs
+++ b/Xamarin.PropertyEditing.Mac/PropertyEditorPanel.cs
@@ -53,6 +53,22 @@ namespace Xamarin.PropertyEditing.Mac
}
}
+ public IHostResourceProvider HostResourceProvider
+ {
+ get => this.hostResources;
+ set
+ {
+ if (this.hostResources == value)
+ return;
+ if (value == null)
+ throw new ArgumentNullException (nameof (value), "Cannot set HostResourceProvider to null");
+
+ this.hostResources = value;
+ if (this.propertyTable.Delegate != null)
+ this.propertyTable.Delegate = new PropertyTableDelegate (value, this.dataSource);
+ }
+ }
+
public TargetPlatform TargetPlatform
{
get { return this.targetPlatform; }
@@ -66,7 +82,7 @@ namespace Xamarin.PropertyEditing.Mac
this.targetPlatform = value;
this.viewModel = new PanelViewModel (value);
this.dataSource = new PropertyTableDataSource (this.viewModel);
- this.propertyTable.Delegate = new PropertyTableDelegate (this.dataSource);
+ this.propertyTable.Delegate = new PropertyTableDelegate (HostResourceProvider, this.dataSource);
this.propertyTable.DataSource = this.dataSource;
OnVmPropertyChanged (this.viewModel, new PropertyChangedEventArgs (null));
@@ -87,8 +103,6 @@ namespace Xamarin.PropertyEditing.Mac
public ICollection<object> SelectedItems => this.viewModel.SelectedObjects;
- public static Themes.MacThemeManager ThemeManager = new Themes.MacThemeManager ();
-
public void Select (IEnumerable<object> selectedItems)
{
if (selectedItems == null)
@@ -97,8 +111,16 @@ namespace Xamarin.PropertyEditing.Mac
((ObservableCollectionEx<object>)SelectedItems).Reset (selectedItems);
}
+ public override void ViewDidChangeEffectiveAppearance ()
+ {
+ this.propertyArrangeMode.Font = HostResourceProvider.GetNamedFont (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize);
+ this.propertyFilter.Font = HostResourceProvider.GetNamedFont (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize);
+
+ this.propertyTable.BackgroundColor = this.hostResources.GetNamedColor (NamedResources.PadBackgroundColor);
+ }
+
+ private IHostResourceProvider hostResources = new HostResourceProvider ();
private bool isArrangeEnabled = true;
- // when this property changes, need to create new datasource
private TargetPlatform targetPlatform;
private NSOutlineView propertyTable;
private PropertyTableDataSource dataSource;
@@ -127,7 +149,6 @@ namespace Xamarin.PropertyEditing.Mac
this.propertyArrangeMode = new NSComboBox {
ControlSize = controlSize,
Editable = false,
- Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize),
TranslatesAutoresizingMaskIntoConstraints = false,
};
@@ -138,7 +159,6 @@ namespace Xamarin.PropertyEditing.Mac
this.propertyFilter = new NSSearchField {
ControlSize = controlSize,
- Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize),
PlaceholderString = LocalizationResources.PropertyFilterLabel,
TranslatesAutoresizingMaskIntoConstraints = false,
};
@@ -192,21 +212,7 @@ namespace Xamarin.PropertyEditing.Mac
NSLayoutConstraint.Create (tableContainer, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1f, -37f),
});
- ThemeManager.ThemeChanged += ThemeManager_ThemeChanged;
-
- UpdateTheme ();
- }
-
- protected override void Dispose (bool disposing)
- {
- if (disposing) {
- PropertyEditorPanel.ThemeManager.ThemeChanged -= ThemeManager_ThemeChanged;
- }
- }
-
- private void ThemeManager_ThemeChanged (object sender, EventArgs e)
- {
- UpdateTheme ();
+ ViewDidChangeEffectiveAppearance ();
}
private void OnPropertiesChanged (object sender, EventArgs e)
@@ -228,11 +234,6 @@ namespace Xamarin.PropertyEditing.Mac
((PropertyTableDelegate)this.propertyTable.Delegate).UpdateExpansions (this.propertyTable);
}
- private void UpdateTheme ()
- {
- Appearance = ThemeManager.CurrentAppearance;
- }
-
private void OnVmPropertyChanged (object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof (PanelViewModel.ArrangeMode) || String.IsNullOrEmpty (e.PropertyName))
diff --git a/Xamarin.PropertyEditing.Mac/PropertyEditorSelector.cs b/Xamarin.PropertyEditing.Mac/PropertyEditorSelector.cs
index f3f2afd..d3a7398 100644
--- a/Xamarin.PropertyEditing.Mac/PropertyEditorSelector.cs
+++ b/Xamarin.PropertyEditing.Mac/PropertyEditorSelector.cs
@@ -9,8 +9,11 @@ namespace Xamarin.PropertyEditing.Mac
{
internal class PropertyEditorSelector
{
- public virtual IEditorView GetEditor (EditorViewModel vm)
+ public virtual IEditorView GetEditor (IHostResourceProvider hostResources, EditorViewModel vm)
{
+ if (hostResources == null)
+ throw new ArgumentNullException (nameof (hostResources));
+
Type[] genericArgs = null;
Type controlType;
Type propertyType = vm.GetType ();
@@ -32,7 +35,7 @@ namespace Xamarin.PropertyEditing.Mac
controlType = controlType.MakeGenericType (genericArgs);
}
- return (IEditorView)Activator.CreateInstance (controlType);
+ return (IEditorView)Activator.CreateInstance (controlType, hostResources);
}
private static readonly Dictionary<Type, Type> ViewModelTypes = new Dictionary<Type, Type> {
@@ -41,9 +44,6 @@ namespace Xamarin.PropertyEditing.Mac
{typeof (PropertyViewModel<bool?>), typeof (BooleanEditorControl)},
{typeof (PredefinedValuesViewModel<>), typeof(PredefinedValuesEditor<>)},
{typeof (CombinablePropertyViewModel<>), typeof(CombinablePropertyEditor<>)},
- {typeof (PropertyViewModel<CoreGraphics.CGPoint>), typeof (CGPointEditorControl)},
- {typeof (PropertyViewModel<CoreGraphics.CGRect>), typeof (CGRectEditorControl)},
- {typeof (PropertyViewModel<CoreGraphics.CGSize>), typeof (CGSizeEditorControl)},
{typeof (PointPropertyViewModel), typeof (CommonPointEditorControl) },
{typeof (RectanglePropertyViewModel), typeof (CommonRectangleEditorControl) },
{typeof (SizePropertyViewModel), typeof (CommonSizeEditorControl) },
diff --git a/Xamarin.PropertyEditing.Mac/PropertyGroupedEditorSelector.cs b/Xamarin.PropertyEditing.Mac/PropertyGroupedEditorSelector.cs
index e1a6574..c3514c6 100644
--- a/Xamarin.PropertyEditing.Mac/PropertyGroupedEditorSelector.cs
+++ b/Xamarin.PropertyEditing.Mac/PropertyGroupedEditorSelector.cs
@@ -8,14 +8,17 @@ namespace Xamarin.PropertyEditing.Mac
internal class PropertyGroupedEditorSelector
: PropertyEditorSelector
{
- public override IEditorView GetEditor (EditorViewModel vm)
+ public override IEditorView GetEditor (IHostResourceProvider hostResources, EditorViewModel vm)
{
+ if (hostResources == null)
+ throw new ArgumentNullException (nameof (hostResources));
+
Type propertyType = vm.GetType ();
if (GroupedViewModelTypes.TryGetValue (propertyType, out Type nativeEditorType)) {
- return (IEditorView)Activator.CreateInstance (nativeEditorType);
+ return (IEditorView)Activator.CreateInstance (nativeEditorType, hostResources);
}
- return base.GetEditor (vm);
+ return base.GetEditor (hostResources, vm);
}
private static readonly Dictionary<Type, Type> GroupedViewModelTypes = new Dictionary<Type, Type> {
diff --git a/Xamarin.PropertyEditing.Mac/PropertyInlinePreviewSelector.cs b/Xamarin.PropertyEditing.Mac/PropertyInlinePreviewSelector.cs
index 5eebc7d..6e8a821 100644
--- a/Xamarin.PropertyEditing.Mac/PropertyInlinePreviewSelector.cs
+++ b/Xamarin.PropertyEditing.Mac/PropertyInlinePreviewSelector.cs
@@ -7,18 +7,18 @@ namespace Xamarin.PropertyEditing.Mac
{
internal abstract class ValueViewSelector
{
- public abstract IValueView CreateView (Type valueType);
+ public abstract IValueView CreateView (IHostResourceProvider hostResources, Type valueType);
}
internal class PropertyInlinePreviewSelector
: ValueViewSelector
{
- public override IValueView CreateView (Type valueType)
+ public override IValueView CreateView (IHostResourceProvider hostResources, Type valueType)
{
if (!ValueTypes.TryGetValue (valueType, out Type viewType))
return null;
- return (IValueView)Activator.CreateInstance (viewType);
+ return (IValueView)Activator.CreateInstance (viewType, hostResources);
}
private static readonly Dictionary<Type, Type> ValueTypes = new Dictionary<Type, Type> {
diff --git a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs
index 7a0209a..92e4382 100644
--- a/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs
+++ b/Xamarin.PropertyEditing.Mac/PropertyTableDelegate.cs
@@ -12,9 +12,15 @@ namespace Xamarin.PropertyEditing.Mac
internal class PropertyTableDelegate
: NSOutlineViewDelegate
{
- public PropertyTableDelegate (PropertyTableDataSource datasource)
+ public PropertyTableDelegate (IHostResourceProvider hostResources, PropertyTableDataSource dataSource)
{
- this.dataSource = datasource;
+ if (hostResources == null)
+ throw new ArgumentNullException (nameof (hostResources));
+ if (dataSource == null)
+ throw new ArgumentNullException (nameof (dataSource));
+
+ this.hostResources = hostResources;
+ this.dataSource = dataSource;
}
public void UpdateExpansions (NSOutlineView outlineView)
@@ -68,7 +74,7 @@ namespace Xamarin.PropertyEditing.Mac
NSView editorOrContainer = null;
if (this.firstCache.TryGetValue (cellIdentifier, out IEditorView editor)) {
this.firstCache.Remove (cellIdentifier);
- editorOrContainer = (editor.NativeView is PropertyEditorControl) ? new EditorContainer (editor) : editor.NativeView;
+ editorOrContainer = (editor.NativeView is PropertyEditorControl) ? new EditorContainer (this.hostResources, editor) : editor.NativeView;
} else {
editorOrContainer = GetEditor (cellIdentifier, evm, outlineView);
editor = ((editorOrContainer as EditorContainer)?.EditorView) ?? editorOrContainer as IEditorView;
@@ -187,6 +193,7 @@ namespace Xamarin.PropertyEditing.Mac
private bool isExpanding;
private readonly PropertyEditorSelector editorSelector = new PropertyEditorSelector ();
+ private readonly IHostResourceProvider hostResources;
private readonly Dictionary<string, EditorRegistration> registrations = new Dictionary<string, EditorRegistration> ();
private readonly Dictionary<string, IEditorView> firstCache = new Dictionary<string, IEditorView> ();
@@ -197,7 +204,7 @@ namespace Xamarin.PropertyEditing.Mac
return view;
if (vm != null) {
- IEditorView editor = this.editorSelector.GetEditor (vm);
+ IEditorView editor = this.editorSelector.GetEditor (this.hostResources, vm);
var editorControl = editor?.NativeView as PropertyEditorControl;
if (editorControl != null) {
@@ -207,9 +214,9 @@ namespace Xamarin.PropertyEditing.Mac
return editor.NativeView;
}
- return new EditorContainer (editor) { Identifier = identifier };
+ return new EditorContainer (this.hostResources, editor) { Identifier = identifier };
} else
- return new PanelHeaderEditorControl ();
+ return new PanelHeaderEditorControl (this.hostResources);
}
private void GetVMGroupCellItendifiterFromFacade (NSObject item, out EditorViewModel vm, out PanelGroupViewModel group, out string cellIdentifier)
diff --git a/Xamarin.PropertyEditing.Mac/Themes/MacThemeManager.cs b/Xamarin.PropertyEditing.Mac/Themes/MacThemeManager.cs
deleted file mode 100644
index 0f61201..0000000
--- a/Xamarin.PropertyEditing.Mac/Themes/MacThemeManager.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System;
-using System.Drawing;
-using System.Collections.Generic;
-using AppKit;
-
-namespace Xamarin.PropertyEditing.Themes
-{
- public class MacThemeManager : BaseThemeManager
- {
- public NSAppearance CurrentAppearance { get; private set; }
- private Dictionary<string, NSImage> themeCache = new Dictionary<string, NSImage> ();
-
- NSAppearance DarkAppearance = NSAppearance.GetAppearance (NSAppearance.NameVibrantDark);
- NSAppearance LightAppearance = NSAppearance.GetAppearance (NSAppearance.NameAqua);
-
- protected override void SetTheme ()
- {
- switch (Theme) {
- case PropertyEditorTheme.Dark:
- CurrentAppearance = DarkAppearance;
- break;
-
- case PropertyEditorTheme.Light:
- CurrentAppearance = LightAppearance;
- break;
-
- case PropertyEditorTheme.None:
- CurrentAppearance = NSAppearance.CurrentAppearance;
- break;
- }
-
- this.themeCache.Clear ();
- }
-
- public string GetImageNameForTheme (string imageNamed, bool selected = false)
- {
- return (Theme == PropertyEditorTheme.Dark ? imageNamed + "~dark" : imageNamed) + (selected ? "~sel" : string.Empty);
- }
-
- public NSImage GetImageForTheme (string imageNamed, bool selected = false)
- {
- var imageNameForTheme = GetImageNameForTheme (imageNamed, selected);
-
- if (!this.themeCache.TryGetValue (imageNameForTheme, out NSImage themeImage)) {
- themeImage = NSImage.ImageNamed (imageNameForTheme);
- this.themeCache[imageNameForTheme] = themeImage;
- }
- return themeImage;
- }
- }
-}
diff --git a/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj b/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj
index c2dc90d..ac84da4 100644
--- a/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj
+++ b/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj
@@ -70,12 +70,9 @@
<Compile Include="Controls\BooleanEditorControl.cs" />
<Compile Include="Controls\ConstraintExtensions.cs" />
<Compile Include="Controls\BaseRectangleEditorControl.cs" />
- <Compile Include="Controls\CGRectEditorControl.cs" />
- <Compile Include="Controls\CGPointEditorControl.cs" />
<Compile Include="NSObjectFacade.cs" />
<Compile Include="Controls\PredefinedValuesEditor.cs" />
<Compile Include="Controls\BasePointEditorControl.cs" />
- <Compile Include="Controls\CGSizeEditorControl.cs" />
<Compile Include="Controls\PointEditorControl.cs" />
<Compile Include="Controls\RectangleEditorControl.cs" />
<Compile Include="Controls\SizeEditorControl.cs" />
@@ -143,19 +140,19 @@
<Compile Include="PropertyInlinePreviewSelector.cs" />
<Compile Include="Controls\EditorContainer.cs" />
<Compile Include="Controls\Layout.cs" />
+ <Compile Include="IHostResourceProvider.cs" />
+ <Compile Include="HostResourceProvider.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controls\" />
<Folder Include="Controls\Custom\" />
<Folder Include="Resources\" />
- <Compile Include="Themes\MacThemeManager.cs" />
<Compile Include="Controls\BaseEditorControl.cs" />
<Compile Include="Controls\ErrorMessageView.cs" />
<Folder Include="Controls\RequestResource\" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controls\" />
- <Folder Include="Themes\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Xamarin.PropertyEditing\Xamarin.PropertyEditing.csproj">
diff --git a/Xamarin.PropertyEditing/Themes/BaseThemeManager.cs b/Xamarin.PropertyEditing/Themes/BaseThemeManager.cs
deleted file mode 100644
index 1431591..0000000
--- a/Xamarin.PropertyEditing/Themes/BaseThemeManager.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System;
-
-namespace Xamarin.PropertyEditing.Themes
-{
- public abstract class BaseThemeManager
- {
- PropertyEditorTheme theme;
-
- public BaseThemeManager ()
- {
- NotifyThemeChanged ();
- }
-
- protected abstract void SetTheme ();
-
- public PropertyEditorTheme Theme
- {
- get {
- return theme;
- }
-
- set {
- if (theme != value) {
- theme = value;
- NotifyThemeChanged ();
- }
- }
- }
-
- void NotifyThemeChanged ()
- {
- SetTheme ();
- ThemeChanged?.Invoke (null, EventArgs.Empty);
- }
-
- public event EventHandler ThemeChanged;
- }
-}
diff --git a/Xamarin.PropertyEditing/Themes/PropertyEditorTheme.cs b/Xamarin.PropertyEditing/Themes/PropertyEditorTheme.cs
deleted file mode 100644
index efe9ac5..0000000
--- a/Xamarin.PropertyEditing/Themes/PropertyEditorTheme.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace Xamarin.PropertyEditing.Themes
-{
- public enum PropertyEditorTheme
- {
- Dark,
- Light,
- None,
- }
-}
diff --git a/Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj b/Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj
index 39ba238..35df7c9 100644
--- a/Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj
+++ b/Xamarin.PropertyEditing/Xamarin.PropertyEditing.csproj
@@ -173,10 +173,6 @@
<Compile Include="ViewModels\IPropertyValue.cs" />
</ItemGroup>
<ItemGroup>
- <Compile Include="Themes\BaseThemeManager.cs" />
- <Compile Include="Themes\PropertyEditorTheme.cs" />
- </ItemGroup>
- <ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>