diff options
author | Eric Maupin <me@ermau.com> | 2018-07-19 00:45:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-19 00:45:02 +0300 |
commit | db47a4b99976b7cee9a6e6130bd9a361e374b01d (patch) | |
tree | 628d6519f4da85180b32faed9975f5b2ed3b26e3 /Xamarin.PropertyEditing.Tests | |
parent | 8a2e35636b82e40b19cc3291e422fde2dd7bc894 (diff) | |
parent | 08390a1dec6043afe02806aaf052b7311d2dc7aa (diff) |
Merge pull request #308 from xamarin/lewing-mac-solidcolor
Mac brush editors
Diffstat (limited to 'Xamarin.PropertyEditing.Tests')
-rw-r--r-- | Xamarin.PropertyEditing.Tests/MockControls/MockNSButton.cs | 5 | ||||
-rw-r--r-- | Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs | 53 |
2 files changed, 56 insertions, 2 deletions
diff --git a/Xamarin.PropertyEditing.Tests/MockControls/MockNSButton.cs b/Xamarin.PropertyEditing.Tests/MockControls/MockNSButton.cs index baa6986..bd69a31 100644 --- a/Xamarin.PropertyEditing.Tests/MockControls/MockNSButton.cs +++ b/Xamarin.PropertyEditing.Tests/MockControls/MockNSButton.cs @@ -1,4 +1,6 @@ -namespace Xamarin.PropertyEditing.Tests.MockControls +using Xamarin.PropertyEditing.Drawing; + +namespace Xamarin.PropertyEditing.Tests.MockControls { public class MockNSButton : MockNSControl { @@ -9,6 +11,7 @@ AddProperty<string> ("AlternateTitle"); AddProperty<NotImplemented> ("AttributedAlternateTitle"); AddProperty<NotImplemented> ("AttributedTitle"); + AddProperty<CommonBrush> ("BackgroundColor"); AddProperty<NSBezelStyle> ("BezelStyle"); AddProperty<bool> ("Bordered"); AddProperty<NotImplemented> ("Cell"); diff --git a/Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs b/Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs index 1f41595..df992ca 100644 --- a/Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs +++ b/Xamarin.PropertyEditing.Tests/MockControls/MockSampleControl.cs @@ -1,12 +1,14 @@ using System; using System.Collections; +using System.Threading.Tasks; using Xamarin.PropertyEditing.Drawing; +using Xamarin.PropertyEditing.Tests.MockPropertyInfo; namespace Xamarin.PropertyEditing.Tests.MockControls { public class MockSampleControl : MockControl { - public MockSampleControl() + public MockSampleControl () { AddProperty<bool> ("Boolean", ReadWrite); AddProperty<bool> ("UnsetBoolean", ReadWrite, valueSources: ValueSources.Local); @@ -38,7 +40,28 @@ namespace Xamarin.PropertyEditing.Tests.MockControls AddProperty<NotImplemented> ("Uncategorized", None); + // TODO: Move the declaration of this property to MockSampleControl once SolidBrush is supported on both platforms. + this.brushPropertyInfo = new MockBrushPropertyInfo ( + name: "SolidBrush", + category: null, + canWrite: true, + colorSpaces: new[] { "RGB", "sRGB" }); + AddProperty<CommonBrush> (this.brushPropertyInfo); + + this.materialDesignBrushPropertyInfo = new MockBrushPropertyInfo ( + name: "MaterialDesignBrush", + category: null, + canWrite: true); + AddProperty<CommonBrush> (this.materialDesignBrushPropertyInfo); + + this.readOnlyBrushPropertyInfo = new MockBrushPropertyInfo ( + name: "ReadOnlySolidBrush", + category: null, + canWrite: false); + AddProperty<CommonBrush> (this.readOnlyBrushPropertyInfo); + AddEvents ("Click", "Hover", "Focus"); + } // Categories @@ -69,5 +92,33 @@ namespace Xamarin.PropertyEditing.Tests.MockControls FlagHasValueTwo = 2, FlagHasValueFour = 4, } + + public async Task SetBrushInitialValueAsync (IObjectEditor editor, CommonBrush brush) + { + if (this.brushSet) return; + await editor.SetValueAsync (this.brushPropertyInfo, new ValueInfo<CommonBrush> { Value = brush }); + this.brushSet = true; + } + + public async Task SetMaterialDesignBrushInitialValueAsync (IObjectEditor editor, CommonBrush brush) + { + if (this.materialDesignBrushSet) return; + await editor.SetValueAsync (this.materialDesignBrushPropertyInfo, new ValueInfo<CommonBrush> { Value = brush }); + this.materialDesignBrushSet = true; + } + + public async Task SetReadOnlyBrushInitialValueAsync (IObjectEditor editor, CommonBrush brush) + { + if (this.readOnlyBrushSet) return; + await editor.SetValueAsync (this.readOnlyBrushPropertyInfo, new ValueInfo<CommonBrush> { Value = brush }); + this.readOnlyBrushSet = true; + } + + private IPropertyInfo brushPropertyInfo; + private IPropertyInfo materialDesignBrushPropertyInfo; + private IPropertyInfo readOnlyBrushPropertyInfo; + private bool brushSet = false; + private bool materialDesignBrushSet = false; + private bool readOnlyBrushSet = false; } } |