diff options
Diffstat (limited to 'Xamarin.PropertyEditing.Windows.Standalone')
4 files changed, 50 insertions, 7 deletions
diff --git a/Xamarin.PropertyEditing.Windows.Standalone/MainWindow.xaml b/Xamarin.PropertyEditing.Windows.Standalone/MainWindow.xaml index 8032f3f..4671d60 100644 --- a/Xamarin.PropertyEditing.Windows.Standalone/MainWindow.xaml +++ b/Xamarin.PropertyEditing.Windows.Standalone/MainWindow.xaml @@ -1,4 +1,4 @@ -<Window x:Class="Xamarin.PropertyEditing.Windows.Standalone.MainWindow" +<Window x:Class="Xamarin.PropertyEditing.Windows.Standalone.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" diff --git a/Xamarin.PropertyEditing.Windows.Standalone/MainWindow.xaml.cs b/Xamarin.PropertyEditing.Windows.Standalone/MainWindow.xaml.cs index 7f58b92..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.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 17d9317..9e26a3b 100644 --- a/Xamarin.PropertyEditing.Windows.Standalone/MockedSampleControlButton.cs +++ b/Xamarin.PropertyEditing.Windows.Standalone/MockedSampleControlButton.cs @@ -1,8 +1,39 @@ +using System.Threading.Tasks; +using Xamarin.PropertyEditing.Drawing; using Xamarin.PropertyEditing.Tests.MockControls; namespace Xamarin.PropertyEditing.Windows.Standalone { - public class MockedSampleControlButton: MockedControlButton<MockSampleControl> { - public MockedSampleControlButton () : base(new MockSampleControl ()) { } + public class MockedSampleControlButton : MockedControlButton<MockSampleControl> + { + public MockedSampleControlButton () : base (new MockSampleControl ()) + { + // TODO: Move the declaration of this property to MockSampleControl once SolidBrush is supported on both platforms. + this.brushPropertyInfo = new BrushPropertyInfo ( + name: "SolidBrush", + category: "Windows Only", + canWrite: true, + colorSpaces: new[] { "RGB", "sRGB" }); + MockedControl.AddProperty<CommonBrush> (this.brushPropertyInfo); + + this.readOnlyBrushPropertyInfo = new BrushPropertyInfo ( + name: "ReadOnlySolidBrush", + category: "Windows Only", + canWrite: false); + 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; } } diff --git a/Xamarin.PropertyEditing.Windows.Standalone/MockedWpfControlButton.cs b/Xamarin.PropertyEditing.Windows.Standalone/MockedWpfControlButton.cs index 5bce465..55e7dfd 100644 --- a/Xamarin.PropertyEditing.Windows.Standalone/MockedWpfControlButton.cs +++ b/Xamarin.PropertyEditing.Windows.Standalone/MockedWpfControlButton.cs @@ -1,3 +1,4 @@ +using System.Windows.Controls; using Xamarin.PropertyEditing.Tests.MockControls; namespace Xamarin.PropertyEditing.Windows.Standalone |