summaryrefslogtreecommitdiff
path: root/reference/csharp/ui
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/ui
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/ui')
-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
3 files changed, 30 insertions, 39 deletions
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