diff options
author | Larry Ewing <lewing@microsoft.com> | 2018-07-15 21:34:46 +0300 |
---|---|---|
committer | Larry Ewing <lewing@microsoft.com> | 2018-07-16 22:05:49 +0300 |
commit | c0c1bfd17237a71a96c9dc0429119f1a066c8bc9 (patch) | |
tree | 7a22712256801f74948932aa41be972365cdf4f3 /Xamarin.PropertyEditing.Mac/Controls | |
parent | c8c7f697599d185efedbd76c4fc7ec00e29a821b (diff) |
[mac] use the Normal/Accent properties when selecting materials
Add the idea of MaterialColorType so that we can target the
correct property on the MaterialDesign model when selecting
colors.
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls')
-rw-r--r-- | Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialColorLayer.cs | 9 | ||||
-rw-r--r-- | Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs | 14 |
2 files changed, 21 insertions, 2 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialColorLayer.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialColorLayer.cs index 02ba820..418b5ca 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialColorLayer.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialColorLayer.cs @@ -4,6 +4,13 @@ using Xamarin.PropertyEditing.Drawing; namespace Xamarin.PropertyEditing.Mac { + public enum MaterialColorType + { + Palette, + Normal, + Accent + } + class MaterialColorLayer : CATextLayer { public MaterialColorLayer () @@ -15,6 +22,8 @@ namespace Xamarin.PropertyEditing.Mac CornerRadius = 3 }; + public MaterialColorType ColorType { get; set; } = MaterialColorType.Palette; + private string text; public string Text { get => this.text; diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs index 758ce57..c9fced8 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/MaterialView.cs @@ -67,7 +67,6 @@ namespace Xamarin.PropertyEditing.Mac FontSize = 12, ContentsScale = NSScreen.MainScreen.BackingScaleFactor, TextAlignmentMode = CATextLayerAlignmentMode.Center, - IsSelected = MaterialDesign.Color == color }; } @@ -117,6 +116,8 @@ namespace Xamarin.PropertyEditing.Mac Layer.AddSublayer (normal); foreach (var color in MaterialDesign.NormalColorScale) { var l = CreateLayer (color.Value); + l.ColorType = MaterialColorType.Normal; + l.IsSelected = color.Value == MaterialDesign.NormalColor; l.Frame = new CGRect (x, 0, width, height); normal.AddSublayer (l); x += width; @@ -139,6 +140,8 @@ namespace Xamarin.PropertyEditing.Mac width = Frame.Width / MaterialDesign.AccentColorScale.Count (); foreach (var color in MaterialDesign.AccentColorScale) { var l = CreateLayer (color.Value); + l.ColorType = MaterialColorType.Accent; + l.IsSelected = color.Value == MaterialDesign.AccentColor; l.Frame = new CGRect (x, 0, width, height); accent.AddSublayer (l); x += width; @@ -159,7 +162,14 @@ namespace Xamarin.PropertyEditing.Mac for (var c = hit; c != null; c = c.SuperLayer) { var editor = c as MaterialColorLayer; if (editor != null) { - ViewModel.Solid.Color = editor.BackgroundColor; + switch (editor.ColorType) { + case MaterialColorType.Accent: + MaterialDesign.AccentColor = editor.BackgroundColor; + break; + default: + MaterialDesign.NormalColor = editor.BackgroundColor; + break; + } NeedsLayout = true; } } |