summaryrefslogtreecommitdiff
path: root/reference
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 /reference
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
Diffstat (limited to 'reference')
-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
12 files changed, 136 insertions, 112 deletions
diff --git a/reference/csharp/core/src/core_event.cs b/reference/csharp/core/src/core_event.cs
index 7906f41e..cadfa997 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 1a0fb5c2..33bc1989 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 502e08cf..8e129e21 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 dd7a3be8..0e594b7d 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 7b155e70..64ade56f 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 61d31dca..e8a03973 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 e04dc205..0253bc39 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 86627e9f..fb64ba4a 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 3f3308ea..2e277f54 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 d5948bdf..bd0e210c 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 fd1bdf15..609bfb36 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 f84fc4bd..96a2b967 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