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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
using System;
using System.Runtime.InteropServices;
using Crow;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
namespace tests
{
public class MainClass : Interface
{
[DllImport ("dl", CallingConvention=CallingConvention.Cdecl)]
static extern IntPtr dlopen (string file, dlmode mode);
[DllImport ("dl", CallingConvention=CallingConvention.Cdecl)]
static extern int dlclose (IntPtr handle);
//void *dlsym(void *restrict handle, const char *restrict name); [Option End]
[DllImport ("dl", CallingConvention=CallingConvention.Cdecl)]
static extern IntPtr dlsym (IntPtr libHnd, string funcName);
[DllImport ("mono-2.0", CallingConvention=CallingConvention.Cdecl)]
static extern void mono_add_internal_call (string signature, IntPtr funcPtr);
[DllImport ("__Internal", EntryPoint="cairo_stroke", CallingConvention=CallingConvention.Cdecl)]
public static extern void cairo_stroke_internal (IntPtr ctx);
[DllImport ("__Internal", EntryPoint="cairo_rectangle", CallingConvention=CallingConvention.Cdecl)]
public static extern void cairo_rect_internal (IntPtr ctx, double x, double y, double w, double h);
[DllImport ("__Internal", EntryPoint="cairo_set_source_rgba", CallingConvention=CallingConvention.Cdecl)]
public static extern void cairo_rgba_internal (IntPtr ctx, double r, double g, double b, double a);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static extern void cairo_stroke (IntPtr ctx);
[Flags]
enum dlmode {
RTLD_LOCAL = 0,
RTLD_LAZY = 0x00001, /* Lazy function call binding. */
RTLD_NOW = 0x00002, /* Immediate function call binding. */
RTLD_BINDING_MASK = 0x3, /* Mask of binding time value. */
RTLD_NOLOAD = 0x00004, /* Do not load the object. */
RTLD_DEEPBIND = 0x00008, /* Use deep binding. */
RTLD_GLOBAL = 0x00100,
}
const string cairoLibPath = @"/opt/cairo/lib/libcairo.so";
//static const string cairoLibPath = @"/opt/cairo/lib/libcairo.so.2.11513.0";
public delegate void Stroke(IntPtr ctx);
public delegate void Cairo4Doubles (IntPtr ctx, double x, double y, double z, double w);
public static Stroke cairo_stroke_func;
public static Cairo4Doubles cairo_rect_func;
public static Cairo4Doubles cairo_set_rgba_func;
/*[DllImport (cairoLibPath, EntryPoint="cairo_stroke")]
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
public static extern void cairo_stroke_icall (IntPtr cr);*/
public string StringTest = "this is a string for testing";
static MainClass app;
public Command CMDTest;
public Measure TestWidth = 100;
public Crow.IML.Instantiator instFileDlg;
public string CurrentDirectory {
get { return Crow.Configuration.Global.Get<string>("CurrentDirectory");}
set {
Crow.Configuration.Global.Set ("CurrentDirectory", value);
}
}
IList<Color> testList = Color.ColorDic.Values.ToList();
public IList<Color> TestList {
set{
testList = value;
NotifyValueChanged ("TestList", testList);
}
get { return testList; }
}
/*public List<KeyValuePair<DbgEvtType, Color>> ColorsKVPList {
get {
return DbgLogViewer.colors.ToList();
}
}*/
protected override void InitBackend ()
{
base.InitBackend ();
//Keyboard.KeyDown += App_KeyboardKeyDown;
}
public static void Main(string[] args)
{
//IntPtr cairoLib = dlopen (cairoLibPath, dlmode.RTLD_LAZY);
//mono_add_internal_call ("tests.MainClass:cairo_stroke_icall(IntPtr cr)", strokeFuncPtr);
/*cairo_stroke_func = Marshal.GetDelegateForFunctionPointer<Stroke>(dlsym (cairoLib, "cairo_stroke"));
cairo_rect_func = Marshal.GetDelegateForFunctionPointer<Cairo4Doubles>(dlsym (cairoLib, "cairo_rectangle"));
cairo_set_rgba_func = Marshal.GetDelegateForFunctionPointer<Cairo4Doubles>(dlsym (cairoLib, "cairo_set_source_rgba"));
*/
foreach (string s in System.Reflection.Assembly.GetEntryAssembly().GetManifestResourceNames())
{
Console.WriteLine(s);
}
using (app = new MainClass ()) {
// XWindow win = new XWindow (app);
// win.Show ();
//app.LoadIMLFragment (@"<SimpleGauge Level='40' Margin='5' Background='Jet' Foreground='Grey' Width='30' Height='50%'/>");
app.CMDTest = new Command(new Action(() => app.AddWidget (app.instFileDlg.CreateInstance()).DataSource = app)) { Caption = "Test", Icon = new SvgPicture("#Tests.image.blank-file.svg"), CanExecute = true};
//app.AddWidget (@"Interfaces/Divers/testFocus.crow").DataSource = app;
//app.AddWidget (@"Interfaces/Divers/testMenu.crow").DataSource = app;
//app.AddWidget (@"Interfaces/Divers/testVisibility.crow").DataSource = app;
//app.Load (@"Interfaces/Divers/0.crow").DataSource = app;
//app.AddWidget (@"Interfaces/Splitter/1.crow").DataSource = app;
app.Load (@"Interfaces/GraphicObject/0.crow").DataSource = app;
//app.AddWidget (@"Interfaces/TemplatedContainer/test_Listbox.crow").DataSource = app;
/*app.instFileDlg = Crow.IML.Instantiator.CreateFromImlFragment
(app, "<FileDialog Caption='Open File' CurrentDirectory='{²CurrentDirectory}'/>");*/
//app.AddWidget (@"Interfaces/Divers/colorPicker.crow").DataSource = app;
//app.AddWidget ("Interfaces/Divers/perfMeasures.crow").DataSource = app;
/*app.AddWidget ("#Tests.ui.dbgLog.crow").DataSource = app;
GraphicObject go = app.AddWidget ("#Tests.ui.dbgLogColors.crow");
go.DataSource = app;
(go.FindByName("combo") as ComboBox).SelectedItemChanged += combo_selectedItemChanged;
(go.FindByName("kvpList") as ListBox).SelectedItemChanged += kvpList_selectedItemChanged;*/
//app.AddWidget (@"Interfaces/Experimental/testDock.crow").DataSource = app;
/*app.LoadIMLFragment (@"<DockWindow Width='150' Height='150' Name='dock1'/>");
app.LoadIMLFragment (@"<DockWindow Width='150' Height='150' Name='dock2'/>");
app.LoadIMLFragment (@"<DockWindow Width='150' Height='150' Name='dock3'/>");
app.LoadIMLFragment (@"<DockWindow Width='150' Height='150'/>");
app.LoadIMLFragment (@"<DockWindow Width='150' Height='150'/>");
app.LoadIMLFragment (@"<DockWindow Width='150' Height='150'/>");*/
long cpt = 0;
Measure testWidth = 100;
int increment = 1;
while (true) {
cpt++;
/*
testWidth += increment;
if (increment > 0) {
if (testWidth > 500)
increment = -increment;
} else if (testWidth < 100)
increment = -increment;
app.NotifyValueChanged ("TestWidth", testWidth);
*/
/*app.NotifyValueChanged ("CPT", cpt);
if (cpt % 2 == 0)
app.NotifyValueChanged ("TestColor", Color.Red);
else
app.NotifyValueChanged ("TestColor", Color.Blue);*/
/*#if MEASURE_TIME
foreach (PerformanceMeasure m in app.PerfMeasures)
m.NotifyChanges ();
#endif*/
app.ProcessEvents ();
//Thread.Sleep(1);
}
}
/*using (Display disp = new Display())
{
Window win = new Window(disp);
bool running = true;
while (running) {
IntPtr evt = disp.NextEvent;
switch ((EventType)Marshal.ReadInt32(evt))
{
case EventType.KeyPress:
running = false;
break;
}
}
}*/
//dlclose (cairoLib);
}
/*void onColorUpdate (object sender, MouseButtonEventArgs e)
{
DbgLogViewer.colorsConf.Set (selectedEvtType.ToString (), newColor);
DbgLogViewer.colors [selectedEvtType] = newColor;
NotifyValueChanged ("ColorsKVPList", ColorsKVPList);
}
//static DbgEvtType selectedEvtType;
static Color newColor;
static void kvpList_selectedItemChanged (object sender, SelectionChangeEventArgs e)
{
if (e.NewValue == null)
return;
selectedEvtType = ((KeyValuePair<DbgEvtType, Color>)e.NewValue).Key;
}
static void combo_selectedItemChanged (object sender, SelectionChangeEventArgs e)
{
newColor = (Color)e.NewValue;
}*/
void App_KeyboardKeyDown (object sender, KeyEventArgs e)
{
Console.WriteLine((byte)e.Key);
//#if DEBUG_LOG
switch (e.Key) {
case Key.F2:
//DebugLog.save (app);
break;
case Key.F4:
//app.NotifyValueChanged ("ColorsKVPList", app.ColorsKVPList);
break;
case Key.F6:
app.LoadIMLFragment (@"<FileDialog Caption='Open File'/>");
//saveDocking ();
break;
case Key.F7:
//reloadDocking ();
break;
case Key.F8:
app.LoadIMLFragment (@"<DockWindow Width='150' Height='150'/>");
break;
}
//#endif
}
void saveDocking () {
DockStack ds = FindByName ("mainDock") as DockStack;
if (ds == null) {
Console.WriteLine ("main dock not found in graphic tree");
return;
}
string conf = ds.ExportConfig ();
Console.WriteLine ("docking conf = " + conf);
Configuration.Global.Set ("DockingTests", conf);
}
void reloadDocking () {
DockStack ds = FindByName ("mainDock") as DockStack;
if (ds == null) {
Console.WriteLine ("main dock not found in graphic tree");
return;
}
string conf = Configuration.Global.Get<string> ("DockingTests");
if (string.IsNullOrEmpty (conf))
return;
ds.ImportConfig (conf);
}
}
}
|