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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Threading;
using Crow;
namespace Crow
{
public class SampleBase : Interface {
public Version CrowVersion => Assembly.GetAssembly (typeof (Widget)).GetName ().Version;
#region Test values for Binding
public List<Command> Commands;
public int intValue = 500;
VerticalAlignment currentVAlign;
DirectoryInfo curDir = new DirectoryInfo (Path.GetDirectoryName (Assembly.GetEntryAssembly ().Location));
public FileSystemInfo[] CurDirectory => curDir.GetFileSystemInfos ();
public int IntValue {
get => intValue;
set {
if (IntValue == value)
return;
intValue = value;
NotifyValueChanged ("IntValue", intValue);
}
}
public VerticalAlignment CurrentVAlign {
get => currentVAlign;
set {
if (currentVAlign == value)
return;
currentVAlign = value;
NotifyValueChanged ("CurrentVAlign", currentVAlign);
}
}
void onSpinnerValueChange (object sender, ValueChangeEventArgs e) {
if (e.MemberName != "Value")
return;
intValue = Convert.ToInt32 (e.NewValue);
}
void change_alignment (object sender, EventArgs e) {
RadioButton rb = sender as RadioButton;
if (rb == null)
return;
NotifyValueChanged ("alignment", Enum.Parse (typeof (Alignment), rb.Caption));
}
public IEnumerable<String> List2 = new List<string> (new string[]
{
"string1",
"string2",
"string3",
"string4",
"string5",
"string6",
"string7",
"string8",
"string8",
"string8",
"string8",
"string8",
"string8",
"string9"
}
);
public IEnumerable<String> TestList2 {
set {
List2 = value;
NotifyValueChanged ("TestList2", testList);
}
get { return List2; }
}
public class TestClass
{
public string Prop1 { get; set; }
public string Prop2 { get; set; }
public override string ToString ()
=> $"{Prop1}, {Prop2}";
}
public class TestClassVC : IValueChange
{
public event EventHandler<ValueChangeEventArgs> ValueChanged;
public void NotifyValueChanged (object _value, [CallerMemberName] string caller = null)
=> ValueChanged.Raise (this, new ValueChangeEventArgs (caller, _value));
string prop1, prop2;
public string Prop1 {
get => prop1;
set {
if (prop1 == value)
return;
prop1 = value;
NotifyValueChanged (prop1);
}
}
public string Prop2 {
get => prop2;
set {
if (prop2 == value)
return;
prop2 = value;
NotifyValueChanged (prop2);
}
}
public override string ToString ()
=> $"{Prop1}, {Prop2}";
}
TestClass tcInstance;// = new TestClass () { Prop1 = "instance 0 prop1 value", Prop2 = "instance 0 prop2 value" };
TestClassVC tcVCInstance;// = new TestClassVC () { Prop1 = "instance 0 prop1 value", Prop2 = "instance 0 prop2 value" };
TestClass tcInstance1 = new TestClass () { Prop1 = "instance 1 prop1 value", Prop2 = "instance 1 prop2 value" };
TestClassVC tcVCInstance1 = new TestClassVC () { Prop1 = "instance 1 prop1 value", Prop2 = "instance 1 prop2 value" };
TestClass tcInstance2 = new TestClass () { Prop1 = "instance 2 prop1 value", Prop2 = "instance 2 prop2 value" };
TestClassVC tcVCInstance2 = new TestClassVC () { Prop1 = "instance 2 prop1 value", Prop2 = "instance 2 prop2 value" };
public TestClass TcInstance {
get => tcInstance;
set {
if (tcInstance == value)
return;
tcInstance = value;
NotifyValueChanged (tcInstance);
}
}
public TestClassVC TcVCInstance {
get => tcVCInstance;
set {
if (tcVCInstance == value)
return;
tcVCInstance = value;
NotifyValueChanged (tcVCInstance);
}
}
void tcInstance_ChangeProperties_MouseClick (object sender, MouseButtonEventArgs e)
{
}
public void tcInstance_ChangeInstance_MouseClick (object sender, MouseButtonEventArgs e)
{
if (TcInstance == tcInstance1)
TcInstance = tcInstance2;
else
TcInstance = tcInstance1;
}
void tcVCInstance_ChangeInstance_MouseClick (object sender, MouseButtonEventArgs e)
{
TcVCInstance = new TestClassVC () { Prop1 = "prop1 value changed", Prop2 = "prop2 value changed" };
}
public IEnumerable<TestClass> List3 = new List<TestClass> (new TestClass[]
{
new TestClass { Prop1 = "string1", Prop2="prop2-1" },
new TestClass { Prop1 = "string2", Prop2="prop2-2" },
new TestClass { Prop1 = "string3", Prop2="prop2-3" },
}
);
public IEnumerable<string> TestList3Props1 => List3.Select (sc => sc.Prop1).ToList ();
public IEnumerable<TestClass> TestList3 {
set {
List3 = value;
NotifyValueChanged ("TestList3", testList);
}
get { return List3; }
}
string prop1;
public string TestList3SelProp1 {
get => prop1;
set {
if (prop1 == value)
return;
prop1 = value;
NotifyValueChanged (prop1);
}
}
string selString;
public string TestList2SelectedString {
get => selString;
set {
if (selString == value)
return;
selString = value;
NotifyValueChanged (selString);
}
}
IList<Colors> testList = (IList<Colors>)FastEnumUtility.FastEnum.GetValues<Colors> ().ToList ();//.ColorDic.Values//.OrderBy(c=>c.Hue)
//.ThenBy(c=>c.Value).ThenBy(c=>c.Saturation)
//.ToList ();
public IList<Colors> TestList {
set {
testList = value;
NotifyValueChanged ("TestList", testList);
}
get { return testList; }
}
void OnClear (object sender, MouseButtonEventArgs e) => TestList = null;
void OnLoadList (object sender, MouseButtonEventArgs e) => TestList = (IList<Colors>)FastEnumUtility.FastEnum.GetValues<Colors> ().ToList ();
string curSources = "";
public string CurSources {
get { return curSources; }
set {
if (value == curSources)
return;
curSources = value;
NotifyValueChanged (curSources);
}
}
bool boolVal = true;
public bool BoolVal {
get { return boolVal; }
set {
if (boolVal == value)
return;
boolVal = value;
NotifyValueChanged (boolVal);
}
}
#endregion
protected override void OnInitialized ()
{
Commands = new List<Command> {
new Command(() => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu 1 clicked")) { Caption = "Action 1" },
new Command(() => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu 2 clicked")) { Caption = "Action 2" },
new Command(() => MessageBox.ShowModal(this, MessageBox.Type.Information, "context menu 3 clicked")) { Caption = "Action 3" }
};
base.OnInitialized ();
}
}
}
|