summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2019-03-26 11:19:13 +0000
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-03-26 16:24:20 +0100
commitb55e5150c91dd860fe86588adce9e0bb35d60c5b (patch)
tree2b861f118b97910088db08dff7348447af0d99df
parent871add6fe5794b4320f2918d1b17504f8e839230 (diff)
mono examples: Adapt to Efl.Csharp.Application
This class simplifies app development, so the examples have to showcase it. Basically: - Your app inherits form it - You do not need to init() or shutdown() - You override the methods you want (like OnInitialize). Fixes T7655 Differential Revision: https://phab.enlightenment.org/D8477
-rw-r--r--apps/csharp/life/src/life_main.cs34
-rw-r--r--apps/csharp/texteditor/src/texteditor_main.cs23
-rw-r--r--reference/csharp/core/src/core_event.cs28
-rw-r--r--reference/csharp/core/src/core_idler.cs27
-rw-r--r--reference/csharp/core/src/core_poll.cs25
-rw-r--r--reference/csharp/eina/src/eina_array.cs17
-rw-r--r--reference/csharp/eina/src/eina_hash.cs17
-rw-r--r--reference/csharp/eina/src/eina_iterator.cs17
-rw-r--r--reference/csharp/eina/src/eina_list.cs14
-rw-r--r--reference/csharp/eina/src/eina_log.cs17
-rw-r--r--reference/csharp/eina/src/eina_value.cs17
-rw-r--r--reference/csharp/ui/src/focus_main.cs23
-rw-r--r--reference/csharp/ui/src/ui_container.cs23
-rw-r--r--reference/csharp/ui/src/ui_sizing.cs23
-rw-r--r--tutorial/csharp/eo-intro/src/eo_intro_main.cs17
-rw-r--r--tutorial/csharp/hello-gui/src/gui_main.cs27
-rw-r--r--tutorial/csharp/hello-world/src/hello-world.cs23
17 files changed, 197 insertions, 175 deletions
diff --git a/apps/csharp/life/src/life_main.cs b/apps/csharp/life/src/life_main.cs
index 3de8d68..b485b18 100644
--- a/apps/csharp/life/src/life_main.cs
+++ b/apps/csharp/life/src/life_main.cs
@@ -1,9 +1,10 @@
1using System; 1using System;
2 2
3public class LifeWindow 3public class LifeWindow : Efl.Csharp.Application
4{ 4{
5 private LifeBoard lifeBoard; 5 private LifeBoard lifeBoard;
6 private LifeRender lifeRender; 6 private LifeRender lifeRender;
7 private Efl.Ui.Win win;
7 8
8 void ResizeEvt(object sender, EventArgs ev) 9 void ResizeEvt(object sender, EventArgs ev)
9 { 10 {
@@ -14,13 +15,12 @@ public class LifeWindow
14 { 15 {
15 // quit the mainloop 16 // quit the mainloop
16 if (ev.arg == false) 17 if (ev.arg == false)
17 Efl.Ui.Config.Exit(); 18 Efl.App.AppMain.Quit(0);
18 } 19 }
19 20
20 void TouchEvt(object sender, Efl.Input.IInterfacePointerDownEvt_Args ev) 21 void TouchEvt(object sender, Efl.Input.IInterfacePointerDownEvt_Args ev)
21 { 22 {
22 int cellx, celly; 23 int cellx, celly;
23 Efl.Ui.Win win = (Efl.Ui.Win)sender;
24 var position = ev.arg.GetPosition(); 24 var position = ev.arg.GetPosition();
25 lifeRender.CellForCoords(win, position, out cellx, out celly); 25 lifeRender.CellForCoords(win, position, out cellx, out celly);
26 26
@@ -31,14 +31,13 @@ public class LifeWindow
31 31
32 void KeyDownEvt(object sender, Efl.Input.IInterfaceKeyDownEvt_Args ev) 32 void KeyDownEvt(object sender, Efl.Input.IInterfaceKeyDownEvt_Args ev)
33 { 33 {
34 Efl.Ui.Win win = (Efl.Ui.Win)sender;
35 if (ev.arg.GetKey() == "space") 34 if (ev.arg.GetKey() == "space")
36 lifeBoard.TogglePause(win); 35 lifeBoard.TogglePause(win);
37 } 36 }
38 37
39 public LifeWindow() 38 protected override void OnInitialize(Eina.Array<System.String> args)
40 { 39 {
41 Efl.Ui.Win win = new Efl.Ui.Win(parent: null, winName: "Life", winType: Efl.Ui.WinType.Basic); 40 win = new Efl.Ui.Win(parent: null, winName: "Life", winType: Efl.Ui.WinType.Basic);
42 win.SetText("EFL Life"); 41 win.SetText("EFL Life");
43 win.SetAutohide(true); 42 win.SetAutohide(true);
44 43
@@ -61,19 +60,30 @@ public class LifeWindow
61 60
62 lifeBoard.Run(win); 61 lifeBoard.Run(win);
63 } 62 }
63
64 protected override void OnPause() {
65 if (win != null) {
66 lifeBoard.TogglePause(win);
67 }
68 }
69
70 protected override void OnResume() {
71 if (win != null) {
72 lifeBoard.TogglePause(win);
73 }
74 }
75
76 protected override void OnTerminate() {
77 Console.WriteLine("Goodbye.");
78 }
64} 79}
65 80
66public class Example 81public class Example
67{ 82{
68 public static void Main() 83 public static void Main()
69 { 84 {
70 Efl.All.Init(Efl.Components.Ui);
71
72 var lifeWin = new LifeWindow(); 85 var lifeWin = new LifeWindow();
73 86
74 // start the mainloop 87 lifeWin.Launch();
75 Efl.Ui.Config.Run();
76
77 Efl.All.Shutdown();
78 } 88 }
79} 89}
diff --git a/apps/csharp/texteditor/src/texteditor_main.cs b/apps/csharp/texteditor/src/texteditor_main.cs
index e0591f1..e65ec3a 100644
--- a/apps/csharp/texteditor/src/texteditor_main.cs
+++ b/apps/csharp/texteditor/src/texteditor_main.cs
@@ -17,7 +17,7 @@
17 17
18using System; 18using System;
19 19
20public class TextEditor 20public class TextEditor : Efl.Csharp.Application
21{ 21{
22 private Efl.Ui.Win win; // The main window 22 private Efl.Ui.Win win; // The main window
23 private Efl.Ui.Text editorTextBox; // The main text entry 23 private Efl.Ui.Text editorTextBox; // The main text entry
@@ -35,7 +35,7 @@ public class TextEditor
35 private void GUIQuitCb(object sender, Efl.Gfx.IEntityVisibilityChangedEvt_Args ea) 35 private void GUIQuitCb(object sender, Efl.Gfx.IEntityVisibilityChangedEvt_Args ea)
36 { 36 {
37 if (ea.arg == false) 37 if (ea.arg == false)
38 Efl.Ui.Config.Exit(); 38 Efl.App.AppMain.Quit(0);
39 } 39 }
40 40
41 // Enables or disables buttons on the toolbar as required 41 // Enables or disables buttons on the toolbar as required
@@ -151,7 +151,7 @@ public class TextEditor
151 } 151 }
152 152
153 // Builds the user interface for the text editor 153 // Builds the user interface for the text editor
154 public TextEditor() 154 protected override void OnInitialize(Eina.Array<System.String> args)
155 { 155 {
156 // Create a window and initialize it 156 // Create a window and initialize it
157 win = new Efl.Ui.Win(parent: Efl.App.AppMain); 157 win = new Efl.Ui.Win(parent: Efl.App.AppMain);
@@ -180,13 +180,6 @@ public class TextEditor
180 // Initial refresh of the toolbar buttons 180 // Initial refresh of the toolbar buttons
181 GUIToolbarRefresh(); 181 GUIToolbarRefresh();
182 } 182 }
183
184 // This method won't return until the application quits
185 public void Run()
186 {
187 // Start the EFL main loop
188 Efl.Ui.Config.Run();
189 }
190} 183}
191 184
192public class Example 185public class Example
@@ -196,14 +189,8 @@ public class Example
196#endif 189#endif
197 public static void Main() 190 public static void Main()
198 { 191 {
199 // Initialize EFL and all UI components 192 TextEditor editor = new TextEditor();
200 Efl.All.Init(Efl.Components.Ui); 193 editor.Launch();
201
202 var textEditor = new TextEditor();
203 textEditor.Run();
204
205 // Shutdown EFL
206 Efl.All.Shutdown();
207 } 194 }
208} 195}
209 196
diff --git a/reference/csharp/core/src/core_event.cs b/reference/csharp/core/src/core_event.cs
index 7906f41..cadfa99 100644
--- a/reference/csharp/core/src/core_event.cs
+++ b/reference/csharp/core/src/core_event.cs
@@ -7,7 +7,7 @@
7 7
8using System; 8using System;
9 9
10public class Example 10public class Example : Efl.Csharp.Application
11{ 11{
12 // Polling callback 12 // Polling callback
13 private static void PollCb(object sender, EventArgs e) 13 private static void PollCb(object sender, EventArgs e)
@@ -15,14 +15,8 @@ public class Example
15 Console.WriteLine(" Poll from {0}", ((Efl.Object)sender).GetName()); 15 Console.WriteLine(" Poll from {0}", ((Efl.Object)sender).GetName());
16 } 16 }
17 17
18#if WIN32 18 protected override void OnInitialize(Eina.Array<System.String> args)
19 [STAThreadAttribute()]
20#endif
21 public static void Main()
22 { 19 {
23 // Initialize EFL and all UI components
24 Efl.All.Init();
25
26 // Retrieve the application's main loop 20 // Retrieve the application's main loop
27 var mainloop = Efl.App.AppMain; 21 var mainloop = Efl.App.AppMain;
28 mainloop.SetName("Mainloop"); 22 mainloop.SetName("Mainloop");
@@ -57,14 +51,20 @@ public class Example
57 }; 51 };
58 52
59 Console.WriteLine("Waiting for Timer to call back..."); 53 Console.WriteLine("Waiting for Timer to call back...");
54 }
60 55
61 // Start the EFL main loop (and the experiment) 56 protected override void OnTerminate()
62 mainloop.Begin(); 57 {
63
64 // Shutdown EFL
65 Efl.All.Shutdown();
66
67 Console.WriteLine("Application is over"); 58 Console.WriteLine("Application is over");
68 } 59 }
60
61#if WIN32
62 [STAThreadAttribute()]
63#endif
64 public static void Main()
65 {
66 var example = new Example();
67 example.Launch();
68 }
69} 69}
70 70
diff --git a/reference/csharp/core/src/core_idler.cs b/reference/csharp/core/src/core_idler.cs
index 1a0fb5c..33bc198 100644
--- a/reference/csharp/core/src/core_idler.cs
+++ b/reference/csharp/core/src/core_idler.cs
@@ -9,16 +9,10 @@
9 9
10using System; 10using System;
11 11
12public class Example 12public class Example : Efl.Csharp.Application
13{ 13{
14#if WIN32 14 protected override void OnInitialize(Eina.Array<System.String> args)
15 [STAThreadAttribute()]
16#endif
17 public static void Main()
18 { 15 {
19 // Initialize EFL and all UI components
20 Efl.All.Init();
21
22 // Retrieve the application's main loop 16 // Retrieve the application's main loop
23 var mainloop = Efl.App.AppMain; 17 var mainloop = Efl.App.AppMain;
24 18
@@ -34,16 +28,19 @@ public class Example
34 }; 28 };
35 29
36 // Use a timer to exit the application 30 // Use a timer to exit the application
37 var timer = new Efl.LoopTimer(mainloop, 0.01); 31 var timer = new Efl.LoopTimer(mainloop, 0.02);
38 timer.TimerTickEvt += (object sender, EventArgs e) => { 32 timer.TimerTickEvt += (object sender, EventArgs e) => {
39 Console.WriteLine("TIMER: timer callback called, exiting."); 33 Console.WriteLine("TIMER: timer callback called, exiting.");
40 mainloop.Quit(new Eina.Value(0)); 34 mainloop.Quit(0);
41 }; 35 };
36 }
42 37
43 // Start the EFL main loop (and the experiment) 38#if WIN32
44 mainloop.Begin(); 39 [STAThreadAttribute()]
45 40#endif
46 // Shutdown EFL 41 public static void Main()
47 Efl.All.Shutdown(); 42 {
43 var example = new Example();
44 example.Launch();
48 } 45 }
49} 46}
diff --git a/reference/csharp/core/src/core_poll.cs b/reference/csharp/core/src/core_poll.cs
index 502e08c..8e129e2 100644
--- a/reference/csharp/core/src/core_poll.cs
+++ b/reference/csharp/core/src/core_poll.cs
@@ -8,16 +8,10 @@
8 8
9using System; 9using System;
10 10
11public class Example 11public class Example : Efl.Csharp.Application
12{ 12{
13#if WIN32 13 protected override void OnInitialize(Eina.Array<System.String> args)
14 [STAThreadAttribute()]
15#endif
16 public static void Main()
17 { 14 {
18 // Initialize EFL and all UI components
19 Efl.All.Init();
20
21 // Retrieve the application's main loop 15 // Retrieve the application's main loop
22 var mainloop = Efl.App.AppMain; 16 var mainloop = Efl.App.AppMain;
23 17
@@ -36,13 +30,16 @@ public class Example
36 var timer = new Efl.LoopTimer(mainloop, 30); 30 var timer = new Efl.LoopTimer(mainloop, 30);
37 timer.TimerTickEvt += (object sender, EventArgs e) => { 31 timer.TimerTickEvt += (object sender, EventArgs e) => {
38 Console.WriteLine("\nTIMER: timer callback called, exiting."); 32 Console.WriteLine("\nTIMER: timer callback called, exiting.");
39 mainloop.Quit(new Eina.Value(0)); 33 mainloop.Quit(0);
40 }; 34 };
35 }
41 36
42 // Start the EFL main loop (and the experiment) 37#if WIN32
43 mainloop.Begin(); 38 [STAThreadAttribute()]
44 39#endif
45 // Shutdown EFL 40 public static void Main()
46 Efl.All.Shutdown(); 41 {
42 var example = new Example();
43 example.Launch();
47 } 44 }
48} 45}
diff --git a/reference/csharp/eina/src/eina_array.cs b/reference/csharp/eina/src/eina_array.cs
index dd7a3be..0e594b7 100644
--- a/reference/csharp/eina/src/eina_array.cs
+++ b/reference/csharp/eina/src/eina_array.cs
@@ -8,7 +8,7 @@
8 8
9using System; 9using System;
10 10
11public class Example 11public class Example : Efl.Csharp.Application
12{ 12{
13 static Eina.Array<string> CreateArray() 13 static Eina.Array<string> CreateArray()
14 { 14 {
@@ -38,10 +38,8 @@ public class Example
38 return true; 38 return true;
39 } 39 }
40 40
41 public static void Main() 41 protected override void OnInitialize(Eina.Array<System.String> args)
42 { 42 {
43 Efl.All.Init();
44
45 var array = CreateArray(); 43 var array = CreateArray();
46 44
47 // Show the contents of our array 45 // Show the contents of our array
@@ -69,7 +67,16 @@ public class Example
69 67
70 array.Dispose(); 68 array.Dispose();
71 69
72 Efl.All.Shutdown(); 70 Efl.App.AppMain.Quit(0);
71 }
72
73#if WIN32
74 [STAThreadAttribute()]
75#endif
76 public static void Main()
77 {
78 var example = new Example();
79 example.Launch();
73 } 80 }
74} 81}
75 82
diff --git a/reference/csharp/eina/src/eina_hash.cs b/reference/csharp/eina/src/eina_hash.cs
index 7b155e7..64ade56 100644
--- a/reference/csharp/eina/src/eina_hash.cs
+++ b/reference/csharp/eina/src/eina_hash.cs
@@ -12,7 +12,7 @@
12using System; 12using System;
13using System.Collections.Generic; 13using System.Collections.Generic;
14 14
15public class Example 15public class Example : Efl.Csharp.Application
16{ 16{
17 static Eina.Hash<Int32, string> CreateHash() 17 static Eina.Hash<Int32, string> CreateHash()
18 { 18 {
@@ -117,13 +117,20 @@ public class Example
117 phone_book.Dispose(); 117 phone_book.Dispose();
118 } 118 }
119 119
120 public static void Main() 120 protected override void OnInitialize(Eina.Array<System.String> args)
121 { 121 {
122 Efl.All.Init();
123
124 HashDemo(); 122 HashDemo();
125 PhonebookDemo(); 123 PhonebookDemo();
126 124
127 Efl.All.Shutdown(); 125 Efl.App.AppMain.Quit(0);
126 }
127
128#if WIN32
129 [STAThreadAttribute()]
130#endif
131 public static void Main()
132 {
133 var example = new Example();
134 example.Launch();
128 } 135 }
129} 136}
diff --git a/reference/csharp/eina/src/eina_iterator.cs b/reference/csharp/eina/src/eina_iterator.cs
index 61d31dc..e8a0397 100644
--- a/reference/csharp/eina/src/eina_iterator.cs
+++ b/reference/csharp/eina/src/eina_iterator.cs
@@ -10,7 +10,7 @@
10 10
11using System; 11using System;
12 12
13public class Example 13public class Example : Efl.Csharp.Application
14{ 14{
15 static void PrintIterator(Eina.Iterator<string> it) 15 static void PrintIterator(Eina.Iterator<string> it)
16 { 16 {
@@ -55,10 +55,8 @@ public class Example
55 return list; 55 return list;
56 } 56 }
57 57
58 public static void Main() 58 protected override void OnInitialize(Eina.Array<System.String> args)
59 { 59 {
60 Efl.All.Init();
61
62 // Create an Eina.Array and iterate through its contents 60 // Create an Eina.Array and iterate through its contents
63 var array = CreateArray(); 61 var array = CreateArray();
64 var it = array.GetIterator(); 62 var it = array.GetIterator();
@@ -73,6 +71,15 @@ public class Example
73 it.Dispose(); 71 it.Dispose();
74 list.Dispose(); 72 list.Dispose();
75 73
76 Efl.All.Shutdown(); 74 Efl.App.AppMain.Quit(0);
75 }
76
77#if WIN32
78 [STAThreadAttribute()]
79#endif
80 public static void Main()
81 {
82 var example = new Example();
83 example.Launch();
77 } 84 }
78} 85}
diff --git a/reference/csharp/eina/src/eina_list.cs b/reference/csharp/eina/src/eina_list.cs
index e04dc20..0253bc3 100644
--- a/reference/csharp/eina/src/eina_list.cs
+++ b/reference/csharp/eina/src/eina_list.cs
@@ -10,7 +10,7 @@
10using System; 10using System;
11using System.Linq; 11using System.Linq;
12 12
13public class Example 13public class Example : Efl.Csharp.Application
14{ 14{
15 static Eina.List<string> CreateList() 15 static Eina.List<string> CreateList()
16 { 16 {
@@ -23,10 +23,8 @@ public class Example
23 return list; 23 return list;
24 } 24 }
25 25
26 public static void Main() 26 protected override void OnInitialize(Eina.Array<System.String> args)
27 { 27 {
28 Efl.All.Init();
29
30 var list = CreateList(); 28 var list = CreateList();
31 29
32 // Print our list with a simple foreach 30 // Print our list with a simple foreach
@@ -66,6 +64,12 @@ public class Example
66 64
67 list.Dispose(); 65 list.Dispose();
68 66
69 Efl.All.Shutdown(); 67 Efl.App.AppMain.Quit(0);
68 }
69
70 public static void Main()
71 {
72 var example = new Example();
73 example.Launch();
70 } 74 }
71} 75}
diff --git a/reference/csharp/eina/src/eina_log.cs b/reference/csharp/eina/src/eina_log.cs
index 86627e9..fb64ba4 100644
--- a/reference/csharp/eina/src/eina_log.cs
+++ b/reference/csharp/eina/src/eina_log.cs
@@ -8,7 +8,7 @@
8 8
9using System; 9using System;
10 10
11public class Example 11public class Example : Efl.Csharp.Application
12{ 12{
13 static double Divide(int num, int denom) 13 static double Divide(int num, int denom)
14 { 14 {
@@ -48,15 +48,22 @@ public class Example
48 Divides(); 48 Divides();
49 } 49 }
50 50
51 public static void Main() 51 protected override void OnInitialize(Eina.Array<System.String> args)
52 { 52 {
53 Efl.All.Init();
54
55 LogLevels(); 53 LogLevels();
56 54
57 // TODO: missing 55 // TODO: missing
58 //LogCustom(); 56 //LogCustom();
59 57
60 Efl.All.Shutdown(); 58 Efl.App.AppMain.Quit(0);
59 }
60
61#if WIN32
62 [STAThreadAttribute()]
63#endif
64 public static void Main()
65 {
66 var example = new Example();
67 example.Launch();
61 } 68 }
62} 69}
diff --git a/reference/csharp/eina/src/eina_value.cs b/reference/csharp/eina/src/eina_value.cs
index 3f3308e..2e277f5 100644
--- a/reference/csharp/eina/src/eina_value.cs
+++ b/reference/csharp/eina/src/eina_value.cs
@@ -9,7 +9,7 @@
9 9
10using System; 10using System;
11 11
12public class Example 12public class Example : Efl.Csharp.Application
13{ 13{
14 static void ValueInt() 14 static void ValueInt()
15 { 15 {
@@ -47,10 +47,8 @@ public class Example
47 Console.WriteLine("str_val was \"{0}\", converted to int is {1}", str_val, int_val); 47 Console.WriteLine("str_val was \"{0}\", converted to int is {1}", str_val, int_val);
48 } 48 }
49 49
50 public static void Main() 50 protected override void OnInitialize(Eina.Array<System.String> args)
51 { 51 {
52 Efl.All.Init();
53
54 ValueInt(); 52 ValueInt();
55 Console.WriteLine(""); 53 Console.WriteLine("");
56 54
@@ -60,6 +58,15 @@ public class Example
60 ValueConvert(); 58 ValueConvert();
61 Console.WriteLine(""); 59 Console.WriteLine("");
62 60
63 Efl.All.Shutdown(); 61 Efl.App.AppMain.Quit(0);
62 }
63
64#if WIN32
65 [STAThreadAttribute()]
66#endif
67 public static void Main()
68 {
69 var example = new Example();
70 example.Launch();
64 } 71 }
65} 72}
diff --git a/reference/csharp/ui/src/focus_main.cs b/reference/csharp/ui/src/focus_main.cs
index d5948bd..bd0e210 100644
--- a/reference/csharp/ui/src/focus_main.cs
+++ b/reference/csharp/ui/src/focus_main.cs
@@ -1,20 +1,14 @@
1using System; 1using System;
2 2
3public class Example 3public class Example : Efl.Csharp.Application
4{ 4{
5 public static void FocusChangedCb(object sender, EventArgs e) 5 public static void FocusChangedCb(object sender, EventArgs e)
6 { 6 {
7 Console.WriteLine($"Focus for object {((Efl.IText)sender).GetText()} changed to {((Efl.Ui.Widget)sender).GetFocus()}"); 7 Console.WriteLine($"Focus for object {((Efl.IText)sender).GetText()} changed to {((Efl.Ui.Widget)sender).GetFocus()}");
8 } 8 }
9 9
10#if WIN32 10 protected override void OnInitialize(Eina.Array<System.String> args)
11 [STAThreadAttribute()]
12#endif
13 public static void Main()
14 { 11 {
15 // Initialize EFL and all UI components
16 Efl.All.Init(Efl.Components.Ui);
17
18 // Create a window and initialize it 12 // Create a window and initialize it
19 var win = new Efl.Ui.Win(null); 13 var win = new Efl.Ui.Win(null);
20 win.SetWinType(Efl.Ui.WinType.Basic); 14 win.SetWinType(Efl.Ui.WinType.Basic);
@@ -71,12 +65,15 @@ public class Example
71 65
72 // Show the focus highlight 66 // Show the focus highlight
73 win.SetFocusHighlightEnabled(true); 67 win.SetFocusHighlightEnabled(true);
68 }
74 69
75 // Start the EFL main loop 70#if WIN32
76 Efl.Ui.Config.Run(); 71 [STAThreadAttribute()]
77 72#endif
78 // Shutdown EFL 73 public static void Main()
79 Efl.All.Shutdown(); 74 {
75 var example = new Example();
76 example.Launch();
80 } 77 }
81} 78}
82 79
diff --git a/reference/csharp/ui/src/ui_container.cs b/reference/csharp/ui/src/ui_container.cs
index fd1bdf1..609bfb3 100644
--- a/reference/csharp/ui/src/ui_container.cs
+++ b/reference/csharp/ui/src/ui_container.cs
@@ -7,7 +7,7 @@
7 7
8using System; 8using System;
9 9
10public class Example 10public class Example : Efl.Csharp.Application
11{ 11{
12 // Create a box container full of buttons 12 // Create a box container full of buttons
13 static Efl.Ui.Box CreateBox(Efl.Ui.Win win) 13 static Efl.Ui.Box CreateBox(Efl.Ui.Win win)
@@ -57,14 +57,8 @@ public class Example
57 return table; 57 return table;
58 } 58 }
59 59
60#if WIN32 60 protected override void OnInitialize(Eina.Array<System.String> args)
61 [STAThreadAttribute()]
62#endif
63 public static void Main()
64 { 61 {
65 // Initialize EFL and all UI components
66 Efl.All.Init(Efl.Components.Ui);
67
68 // Create a window and initialize it 62 // Create a window and initialize it
69 Efl.Ui.Win win = new Efl.Ui.Win(null); 63 Efl.Ui.Win win = new Efl.Ui.Win(null);
70 win.SetWinType(Efl.Ui.WinType.Basic); 64 win.SetWinType(Efl.Ui.WinType.Basic);
@@ -110,12 +104,15 @@ public class Example
110 Efl.Ui.Config.Exit(); 104 Efl.Ui.Config.Exit();
111 }; 105 };
112 Efl.IContentConcrete.static_cast(hsplit.GetPart("second")).SetContent(quit_btn); 106 Efl.IContentConcrete.static_cast(hsplit.GetPart("second")).SetContent(quit_btn);
107 }
113 108
114 // Start the EFL main loop 109#if WIN32
115 Efl.Ui.Config.Run(); 110 [STAThreadAttribute()]
116 111#endif
117 // Shutdown EFL 112 public static void Main()
118 Efl.All.Shutdown(); 113 {
114 var example = new Example();
115 example.Launch();
119 } 116 }
120} 117}
121 118
diff --git a/reference/csharp/ui/src/ui_sizing.cs b/reference/csharp/ui/src/ui_sizing.cs
index f84fc4b..96a2b96 100644
--- a/reference/csharp/ui/src/ui_sizing.cs
+++ b/reference/csharp/ui/src/ui_sizing.cs
@@ -8,16 +8,10 @@
8 8
9using System; 9using System;
10 10
11public class Example 11public class Example : Efl.Csharp.Application
12{ 12{
13#if WIN32 13 protected override void OnInitialize(Eina.Array<System.String> args)
14 [STAThreadAttribute()]
15#endif
16 public static void Main()
17 { 14 {
18 // Initialize EFL and all UI components
19 Efl.All.Init(Efl.Components.Ui);
20
21 // Create a window and initialize it 15 // Create a window and initialize it
22 Efl.Ui.Win win = new Efl.Ui.Win(null); 16 Efl.Ui.Win win = new Efl.Ui.Win(null);
23 win.SetWinType(Efl.Ui.WinType.Basic); 17 win.SetWinType(Efl.Ui.WinType.Basic);
@@ -49,12 +43,15 @@ public class Example
49 button.SetText("Big button"); 43 button.SetText("Big button");
50 button.SetHintSizeMin(new Eina.Size2D(100,100)); 44 button.SetHintSizeMin(new Eina.Size2D(100,100));
51 box.DoPack(button); 45 box.DoPack(button);
46 }
52 47
53 // Start the EFL main loop 48#if WIN32
54 Efl.Ui.Config.Run(); 49 [STAThreadAttribute()]
55 50#endif
56 // Shutdown EFL 51 public static void Main()
57 Efl.All.Shutdown(); 52 {
53 var example = new Example();
54 example.Launch();
58 } 55 }
59} 56}
60 57
diff --git a/tutorial/csharp/eo-intro/src/eo_intro_main.cs b/tutorial/csharp/eo-intro/src/eo_intro_main.cs
index db9ce45..4aa8ac6 100644
--- a/tutorial/csharp/eo-intro/src/eo_intro_main.cs
+++ b/tutorial/csharp/eo-intro/src/eo_intro_main.cs
@@ -1,6 +1,6 @@
1using System; 1using System;
2 2
3public class Example 3public class Example : Efl.Csharp.Application
4{ 4{
5 static Efl.GenericModel root, child2; 5 static Efl.GenericModel root, child2;
6 6
@@ -32,16 +32,23 @@ public class Example
32 child2.Dispose(); 32 child2.Dispose();
33 } 33 }
34 34
35 public static void Main() 35 protected override void OnInitialize(Eina.Array<System.String> args)
36 { 36 {
37 Efl.All.Init(Efl.Components.Ui);
38
39 // Create all objects 37 // Create all objects
40 ObjCreate(); 38 ObjCreate();
41 39
42 // Destroy all objects 40 // Destroy all objects
43 ObjDestroy(); 41 ObjDestroy();
44 42
45 Efl.All.Shutdown(); 43 Efl.App.AppMain.Quit(0);
44 }
45
46#if WIN32
47 [STAThreadAttribute()]
48#endif
49 public static void Main()
50 {
51 var example = new Example();
52 example.Launch();
46 } 53 }
47} 54}
diff --git a/tutorial/csharp/hello-gui/src/gui_main.cs b/tutorial/csharp/hello-gui/src/gui_main.cs
index 28ce619..4000c9b 100644
--- a/tutorial/csharp/hello-gui/src/gui_main.cs
+++ b/tutorial/csharp/hello-gui/src/gui_main.cs
@@ -1,23 +1,17 @@
1using System; 1using System;
2 2
3public class Example 3public class Example : Efl.Csharp.Application
4{ 4{
5 // Callback to quit the application 5 // Callback to quit the application
6 public static void QuitCb(object sender, Efl.Gfx.IEntityVisibilityChangedEvt_Args e) 6 public static void QuitCb(object sender, Efl.Gfx.IEntityVisibilityChangedEvt_Args e)
7 { 7 {
8 // Exit the EFL main loop 8 // Exit the EFL main loop
9 if (e.arg == false) 9 if (e.arg == false)
10 Efl.Ui.Config.Exit(); 10 Efl.App.AppMain.Quit(0);
11 } 11 }
12 12
13#if WIN32 13 protected override void OnInitialize(Eina.Array<System.String> args)
14 [STAThreadAttribute()]
15#endif
16 public static void Main()
17 { 14 {
18 // Initialize EFL and all UI components
19 Efl.All.Init(Efl.Components.Ui);
20
21 // Create a window and initialize it 15 // Create a window and initialize it
22 Efl.Ui.Win win = new Efl.Ui.Win(Efl.App.AppMain); 16 Efl.Ui.Win win = new Efl.Ui.Win(Efl.App.AppMain);
23 // Set the window's title 17 // Set the window's title
@@ -52,15 +46,18 @@ public class Example
52 button.SetText("Quit"); 46 button.SetText("Quit");
53 button.SetHintWeight(1.0, 0.1); 47 button.SetHintWeight(1.0, 0.1);
54 // Set the method to be called when the button is pressed 48 // Set the method to be called when the button is pressed
55 button.ClickedEvt += (object sender, EventArgs e) => { Efl.Ui.Config.Exit(); }; 49 button.ClickedEvt += (object sender, EventArgs e) => { Efl.App.AppMain.Quit(0); };
56 // Add the button to the box container 50 // Add the button to the box container
57 box.DoPack(button); 51 box.DoPack(button);
52 }
58 53
59 // Start the EFL main loop 54#if WIN32
60 Efl.Ui.Config.Run(); 55 [STAThreadAttribute()]
61 56#endif
62 // Shutdown EFL 57 public static void Main()
63 Efl.All.Shutdown(); 58 {
59 var example = new Example();
60 example.Launch();
64 } 61 }
65} 62}
66 63
diff --git a/tutorial/csharp/hello-world/src/hello-world.cs b/tutorial/csharp/hello-world/src/hello-world.cs
index a490f92..5d1695f 100644
--- a/tutorial/csharp/hello-world/src/hello-world.cs
+++ b/tutorial/csharp/hello-world/src/hello-world.cs
@@ -1,15 +1,9 @@
1using System; 1using System;
2 2
3public class Example 3public class Example : Efl.Csharp.Application
4{ 4{
5#if WIN32 5 protected override void OnInitialize(Eina.Array<System.String> args)
6 [STAThreadAttribute()]
7#endif
8 public static void Main()
9 { 6 {
10 // Initialize EFL and all UI components
11 Efl.All.Init(Efl.Components.Ui);
12
13 // Create a window and initialize it 7 // Create a window and initialize it
14 Efl.Ui.Win win = new Efl.Ui.Win(Efl.App.AppMain); 8 Efl.Ui.Win win = new Efl.Ui.Win(Efl.App.AppMain);
15 // Set the window's title 9 // Set the window's title
@@ -20,11 +14,14 @@ public class Example
20 // Window size must be explicitly set, otherwise it will be invisible 14 // Window size must be explicitly set, otherwise it will be invisible
21 // due to its lack of content. 15 // due to its lack of content.
22 win.SetSize(new Eina.Size2D(360, 240)); 16 win.SetSize(new Eina.Size2D(360, 240));
17 }
23 18
24 // Start the EFL main loop 19#if WIN32
25 Efl.Ui.Config.Run(); 20 [STAThreadAttribute()]
26 21#endif
27 // Shutdown EFL 22 public static void Main()
28 Efl.All.Shutdown(); 23 {
24 var example = new Example();
25 example.Launch();
29 } 26 }
30} 27}