diff options
Diffstat (limited to 'Xamarin.PropertyEditing.Windows.Standalone')
-rw-r--r-- | Xamarin.PropertyEditing.Windows.Standalone/MainWindow.xaml.cs | 21 | ||||
-rw-r--r-- | Xamarin.PropertyEditing.Windows.Standalone/MockedSampleControlButton.cs | 26 |
2 files changed, 34 insertions, 13 deletions
diff --git a/Xamarin.PropertyEditing.Windows.Standalone/MainWindow.xaml.cs b/Xamarin.PropertyEditing.Windows.Standalone/MainWindow.xaml.cs index 292d8c2..9508b85 100644 --- a/Xamarin.PropertyEditing.Windows.Standalone/MainWindow.xaml.cs +++ b/Xamarin.PropertyEditing.Windows.Standalone/MainWindow.xaml.cs @@ -1,5 +1,6 @@ -using System.Windows; +using System.Windows; using System.Windows.Controls; +using Xamarin.PropertyEditing.Drawing; using Xamarin.PropertyEditing.Tests; namespace Xamarin.PropertyEditing.Windows.Standalone @@ -15,11 +16,21 @@ namespace Xamarin.PropertyEditing.Windows.Standalone this.panel.EditorProvider = new MockEditorProvider (); } - private void Button_Click (object sender, RoutedEventArgs e) + private async void Button_Click (object sender, RoutedEventArgs e) { - var mockedButton = sender as IMockedControl; - var inspectedObject = (mockedButton == null || mockedButton.MockedControl == null) - ? sender : mockedButton.MockedControl; + var mockedControl = sender as IMockedControl; + object inspectedObject; + if (mockedControl == null || mockedControl.MockedControl == null) { + inspectedObject = sender; + } else { + inspectedObject = mockedControl.MockedControl; + if (mockedControl is MockedSampleControlButton mockedButton) { + IObjectEditor editor = await this.panel.EditorProvider.GetObjectEditorAsync (inspectedObject); + await mockedButton.SetBrush (editor, new CommonSolidBrush (20, 120, 220, 240, "sRGB")); + await mockedButton.SetReadOnlyBrush (editor, new CommonSolidBrush (240, 220, 15, 190)); + } + } + if (this.panel.SelectedItems.Contains (inspectedObject)) this.panel.SelectedItems.Remove (inspectedObject); else diff --git a/Xamarin.PropertyEditing.Windows.Standalone/MockedSampleControlButton.cs b/Xamarin.PropertyEditing.Windows.Standalone/MockedSampleControlButton.cs index e2e30e8..9e26a3b 100644 --- a/Xamarin.PropertyEditing.Windows.Standalone/MockedSampleControlButton.cs +++ b/Xamarin.PropertyEditing.Windows.Standalone/MockedSampleControlButton.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Xamarin.PropertyEditing.Drawing; using Xamarin.PropertyEditing.Tests.MockControls; @@ -8,22 +9,31 @@ namespace Xamarin.PropertyEditing.Windows.Standalone public MockedSampleControlButton () : base (new MockSampleControl ()) { // TODO: Move the declaration of this property to MockSampleControl once SolidBrush is supported on both platforms. - var brushPropertyInfo = new BrushPropertyInfo ( + this.brushPropertyInfo = new BrushPropertyInfo ( name: "SolidBrush", category: "Windows Only", canWrite: true, colorSpaces: new[] { "RGB", "sRGB" }); - MockedControl.AddProperty<CommonBrush> (brushPropertyInfo); - MockedControl.SetValue<CommonBrush>(brushPropertyInfo, - new CommonSolidBrush(20, 120, 220, 240, "sRGB")); + MockedControl.AddProperty<CommonBrush> (this.brushPropertyInfo); - var readOnlyBrushPropertyInfo = new BrushPropertyInfo( + this.readOnlyBrushPropertyInfo = new BrushPropertyInfo ( name: "ReadOnlySolidBrush", category: "Windows Only", canWrite: false); - MockedControl.AddProperty<CommonBrush> (readOnlyBrushPropertyInfo); - MockedControl.SetValue<CommonBrush> (readOnlyBrushPropertyInfo, - new CommonSolidBrush (240, 220, 15, 190)); + MockedControl.AddProperty<CommonBrush> (this.readOnlyBrushPropertyInfo); } + + public async Task SetBrush (IObjectEditor editor, CommonBrush brush) + { + await editor.SetValueAsync (this.brushPropertyInfo, new ValueInfo<CommonBrush> { Value = brush }); + } + + public async Task SetReadOnlyBrush (IObjectEditor editor, CommonBrush brush) + { + await editor.SetValueAsync (this.readOnlyBrushPropertyInfo, new ValueInfo<CommonBrush> { Value = brush }); + } + + private IPropertyInfo brushPropertyInfo; + private IPropertyInfo readOnlyBrushPropertyInfo; } } |