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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
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 ()
{
AddProperty<bool> ("Boolean", ReadWrite, valueSources: ValueSources.Local | ValueSources.Resource | ValueSources.Binding);
AddProperty<bool> ("UnsetBoolean", ReadWrite, valueSources: ValueSources.Local);
AddProperty<int> ("Integer", ReadWrite);
AddProperty<int> ("UnsetInteger", ReadWrite, valueSources: ValueSources.Local);
AddProperty<float> ("FloatingPoint", ReadWrite);
AddProperty<string> ("String", ReadWrite, valueSources: ValueSources.Local | ValueSources.Resource | ValueSources.Binding);
AddProperty<Enumeration> ("Enumeration", ReadWrite);
AddProperty<FlagsNoValues> ("FlagsNoValues", ReadWrite, canWrite: true, flag: true);
AddProperty<FlagsWithValues> ("FlagsWithValues", ReadWrite, canWrite: true, flag: true);
AddProperty<CommonPoint> ("Point", ReadWrite);
AddProperty<CommonSize> ("Size", ReadWrite);
AddProperty<CommonRectangle> ("Rectangle", ReadWrite);
// AddProperty<CommonThickness> ("Thickness", ReadWrite); // Lacking support on the mac at this point in time.
AddProperty<object> ("Object", ReadWrite);
AddProperty<IList> ("Collection", ReadWrite);
AddReadOnlyProperty<bool> ("ReadOnlyBoolean", ReadOnly);
AddReadOnlyProperty<int> ("ReadOnlyInteger", ReadOnly);
AddReadOnlyProperty<float> ("ReadOnlyFloatingPoint", ReadOnly);
AddReadOnlyProperty<string> ("ReadOnlyString", ReadOnly);
AddReadOnlyProperty<Enumeration> ("ReadOnlyEnumeration", ReadOnly);
AddProperty<FlagsNoValues> ("ReadOnlyFlagsNotValue", ReadOnly, canWrite: false, flag: true);
AddProperty<FlagsWithValues> ("ReadOnlyFlagsWithValues", ReadOnly, canWrite: false, flag: true);
AddReadOnlyProperty<CommonPoint> ("ReadOnlyPoint", ReadOnly);
AddReadOnlyProperty<CommonSize> ("ReadOnlySize", ReadOnly);
AddReadOnlyProperty<CommonRectangle> ("ReadOnlyRectangle", ReadOnly);
// AddReadOnlyProperty<CommonThickness> ("ReadOnlyThickness", ReadOnly);
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);
this.colorPropertyInfo = new MockPropertyInfo<CommonColor> (
name: "ColorNoBrush",
category: "Windows Only",
canWrite: true,
valueSources: ValueSources.Default | ValueSources.Local | ValueSources.Resource);
AddProperty<CommonColor> (this.colorPropertyInfo);
AddEvents ("Click", "Hover", "Focus");
}
// Categories
public static readonly string ReadWrite = nameof (ReadWrite);
public static readonly string ReadOnly = nameof (ReadOnly);
public static readonly string None = "";
// Some enumeration and flags to test with
public enum Enumeration
{
FirstOption,
SecondOption,
ThirdOption
}
[Flags] // Treated like a 0 based Enum
public enum FlagsNoValues
{
FlagNoValueZero,
FlagNoValueOne,
FlagNoValueTwo,
}
[Flags]
public enum FlagsWithValues
{
FlagHasValueOne = 1,
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 IPropertyInfo colorPropertyInfo;
private bool brushSet = false;
private bool materialDesignBrushSet = false;
private bool readOnlyBrushSet = false;
}
}
|