summaryrefslogtreecommitdiff
path: root/reference/csharp/core
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/csharp/core
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/csharp/core')
-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
3 files changed, 37 insertions, 43 deletions
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}