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
|
using System;
using Crow;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Reflection;
using System.Text;
using System.Diagnostics;
namespace Tests
{
class BasicTests : CrowWindow
{
public BasicTests ()
: base(800, 600,"test: press <F3> to toogle test files")
{
}
int idx = 0;
string[] testFiles;
#region Test values for Binding
public int intValue = 500;
DirectoryInfo curDir = new DirectoryInfo (Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
//DirectoryInfo curDir = new DirectoryInfo (@"/mnt/data/Images");
public FileSystemInfo[] CurDirectory {
get { return curDir.GetFileSystemInfos (); }
}
public int IntValue {
get {
return intValue;
}
set {
intValue = value;
NotifyValueChanged ("IntValue", intValue);
}
}
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 IList<String> List2 = new List<string>(new string[]
{
"string1",
"string2",
"string3",
// "string4",
// "string5",
// "string6",
// "string7",
// "string8",
// "string8",
// "string8",
// "string8",
// "string8",
// "string8",
// "string9"
}
);
public IList<String> TestList2 {
set{
List2 = value;
NotifyValueChanged ("TestList2", testList);
}
get { return List2; }
}
IList<Color> testList = Color.ColorDic.ToList();
public IList<Color> TestList {
set{
testList = value;
NotifyValueChanged ("TestList", testList);
}
get { return testList; }
}
string curSources = "";
public string CurSources {
get { return curSources; }
set {
if (value == curSources)
return;
curSources = value;
NotifyValueChanged ("CurSources", curSources);
}
}
bool boolVal = true;
public bool BoolVal {
get { return boolVal; }
set {
if (boolVal == value)
return;
boolVal = value;
NotifyValueChanged ("BoolVal", boolVal);
}
}
#endregion
void OnClear (object sender, MouseButtonEventArgs e) => TestList = null;
void OnLoadList (object sender, MouseButtonEventArgs e) => TestList = Color.ColorDic.ToList();
protected override void OnLoad (EventArgs e)
{
base.OnLoad (e);
this.KeyDown += KeyboardKeyDown1;
//testFiles = new string [] { @"Interfaces/Unsorted/testFileDialog.crow" };
//testFiles = new string [] { @"Interfaces/Divers/colorPicker.crow" };
testFiles = new string [] { @"Interfaces/Divers/welcome.crow" };
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/GraphicObject", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Container", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Group", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Stack", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/TemplatedControl", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/TemplatedContainer", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/TemplatedGroup", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Splitter", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Wrapper", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Divers", "*.crow")).ToArray ();
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/Unsorted", "*.crow")).ToArray ();
object tc = Color.AirForceBlueRaf;
Load(testFiles[idx]).DataSource = this;
}
void KeyboardKeyDown1 (object sender, OpenTK.Input.KeyboardKeyEventArgs e)
{
if (e.Key == OpenTK.Input.Key.Escape) {
Quit (null, null);
return;
} else if (e.Key == OpenTK.Input.Key.F1) {
TestList.Add ("new string");
NotifyValueChanged ("TestList", TestList);
return;
} else if (e.Key == OpenTK.Input.Key.F4) {
GraphicObject w = Load ("Interfaces/TemplatedContainer/testWindow.goml");
w.DataSource = this;
return;
} else if (e.Key == OpenTK.Input.Key.F5) {
GraphicObject w = Load ("Interfaces/TemplatedContainer/testWindow2.goml");
w.DataSource = this;
return;
}else if (e.Key == OpenTK.Input.Key.F6) {
GraphicObject w = Load ("Interfaces/Divers/0.crow");
w.DataSource = this;
return;
}else if (e.Key == OpenTK.Input.Key.F7) {
GraphicObject w = Load ("Interfaces/Divers/perfMeasures.crow");
w.DataSource = this;
return;
} else if (e.Key == OpenTK.Input.Key.F2)
idx--;
else if (e.Key == OpenTK.Input.Key.F3)
idx++;
else
return;
try {
ClearInterface ();
if (idx == testFiles.Length)
idx = 0;
else if (idx < 0)
idx = testFiles.Length - 1;
this.Title = testFiles [idx] + ". Press <F3> to cycle examples.";
GraphicObject obj = Load (testFiles[idx]);
obj.DataSource = this;
} catch (Exception ex) {
Debug.WriteLine (ex.Message + ex.InnerException);
}
}
// void Tv_SelectedItemChanged (object sender, SelectionChangeEventArgs e)
// {
// FileInfo fi = e.NewValue as FileInfo;
// if (fi == null)
// return;
// if (fi.Extension == ".crow" || fi.Extension == ".goml") {
// Instantiator i = new Instantiator(fi.FullName);
// lock (ifaceControl.CrowInterface.UpdateMutex) {
// (ifaceControl.CrowInterface.FindByName ("crowContainer") as Container).SetChild
// (i.CreateInstance(ifaceControl.CrowInterface));
// //CurSources = i.GetImlSourcesCode();
// }
// }
// }
// void onImlSourceChanged(Object sender, TextChangeEventArgs e){
// Instantiator i;
// try {
// i = Instantiator.CreateFromImlFragment (e.Text);
// } catch (Exception ex) {
// Debug.WriteLine (ex);
// return;
// }
// lock (ifaceControl.CrowInterface.UpdateMutex) {
// (ifaceControl.CrowInterface.FindByName ("crowContainer") as Container).SetChild
// (i.CreateInstance(ifaceControl.CrowInterface));
// }
// }
void onButClick(object send, MouseButtonEventArgs e)
{
Console.WriteLine ("button clicked:" + send.ToString());
}
// void onAddTabButClick(object sender, MouseButtonEventArgs e){
//
// TabView tv = ifaceControl.CrowInterface.FindByName("tabview1") as TabView;
// if (tv == null)
// return;
// tv.AddChild (new TabItem () { Caption = "NewTab" });
// }
[STAThread]
static void Main ()
{
Console.WriteLine ("starting example");
BasicTests win = new BasicTests ();
win.VSync = OpenTK.VSyncMode.Adaptive;
win.Run (30);
}
protected override void OnUpdateFrame (OpenTK.FrameEventArgs e)
{
base.OnUpdateFrame (e);
string test = e.Time.ToString ();
IntValue++;
if (IntValue == 1000)
IntValue = 0;
NotifyValueChanged ("PropertyLessBinding", test);
}
void onNew(object sender, EventArgs e){
Debug.WriteLine ("menu new clicked");
}
}
}
|