1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
using System.Threading.Tasks;
using Xamarin.PropertyEditing.Drawing;
using Xamarin.PropertyEditing.Tests.MockControls;
using Xamarin.PropertyEditing.Tests.MockPropertyInfo;
namespace Xamarin.PropertyEditing.Windows.Standalone
{
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 MockBrushPropertyInfo (
name: "SolidBrush",
category: "Windows Only",
canWrite: true,
colorSpaces: new[] { "RGB", "sRGB" });
MockedControl.AddProperty<CommonBrush> (this.brushPropertyInfo);
this.materialDesignBrushPropertyInfo = new MockBrushPropertyInfo (
name: "MaterialDesignBrush",
category: "Windows Only",
canWrite: true);
MockedControl.AddProperty<CommonBrush> (this.materialDesignBrushPropertyInfo);
this.readOnlyBrushPropertyInfo = new MockBrushPropertyInfo (
name: "ReadOnlySolidBrush",
category: "Windows Only",
canWrite: false);
MockedControl.AddProperty<CommonBrush> (this.readOnlyBrushPropertyInfo);
this.colorPropertyInfo = new MockPropertyInfo<CommonColor> (
name: "ColorNoBrush",
category: "Windows Only",
canWrite: true,
valueSources: ValueSources.Default | ValueSources.Local | ValueSources.Resource);
MockedControl.AddProperty<CommonColor> (this.colorPropertyInfo);
}
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 readonly IPropertyInfo brushPropertyInfo;
private readonly IPropertyInfo materialDesignBrushPropertyInfo;
private readonly IPropertyInfo readOnlyBrushPropertyInfo;
private readonly IPropertyInfo colorPropertyInfo;
private bool brushSet = false;
private bool materialDesignBrushSet = false;
private bool readOnlyBrushSet = false;
}
}
|