summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2018-08-24 11:41:29 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2018-08-24 11:42:01 -0300
commitad936668758288eb54c6acfe3e3226972558ccff (patch)
treedc07625343b135ad686b18ad4a4103dbb98ac1b6
parent006760cdf66c9585ddccedd12705f941147665f5 (diff)
C# Hello Gui tutorial: bring it closer to the C version
Summary: Configure all widgets inside their constructors and a couple more minor things to make the C# Hello Gui more similar to the C version, which should simplify the tutorial. Reviewers: lauromoura, vitor.sousa Reviewed By: vitor.sousa Differential Revision: https://phab.enlightenment.org/D6906
-rw-r--r--tutorial/csharp/hello-gui/src/gui_main.cs66
1 files changed, 31 insertions, 35 deletions
diff --git a/tutorial/csharp/hello-gui/src/gui_main.cs b/tutorial/csharp/hello-gui/src/gui_main.cs
index 0c125552..0c07b6f6 100644
--- a/tutorial/csharp/hello-gui/src/gui_main.cs
+++ b/tutorial/csharp/hello-gui/src/gui_main.cs
@@ -9,59 +9,55 @@ public class Example
9 efl.ui.Config.Exit(); 9 efl.ui.Config.Exit();
10 } 10 }
11 11
12#if WIN32
13 [STAThreadAttribute()]
14#endif
12 public static void Main() 15 public static void Main()
13 { 16 {
14 // Initialize EFL and all UI components 17 // Initialize EFL and all UI components
15 efl.All.Init(efl.Components.Ui); 18 efl.All.Init(efl.Components.Ui);
16 19
17 // Create a window and initialize it 20 // Create a window and initialize it
18 efl.ui.IWin win = new efl.ui.Win(null, (efl.ui.IWin ewin) => { 21 efl.ui.IWin win = new efl.ui.Win(efl.App.GetLoopMain(), (efl.ui.IWin ewin) => {
19 // Request a simple window
20 ewin.SetWinType(efl.ui.Win_Type.Basic);
21 // Set the window's title 22 // Set the window's title
22 ewin.SetText("Hello World"); 23 ewin.SetText("Hello World");
23 // Request that the window is automatically hidden when the "close" 24 // Request that the window is automatically hidden when the "close"
24 // button is pressed 25 // button is pressed
25 ewin.SetAutohide(true); 26 ewin.SetAutohide(true);
27 // Hook to the Hide event
28 ewin.HideEvt += QuitCb;
26 }); 29 });
27 30
28 // Hook to the Hide event
29 win.HideEvt += QuitCb;
30
31 // Create a box container 31 // Create a box container
32 efl.ui.IBox box = new efl.ui.Box(win); 32 efl.ui.IBox box = new efl.ui.Box(win, (efl.ui.IBox ebox) => {
33 // Set its minimum size 33 // Set its minimum size
34 eina.Size2D sz; 34 ebox.SetHintMin(new eina.Size2D(360, 240));
35 sz.W = 360; 35 // Set the box as the content for the window
36 sz.H = 240; 36 // The window size will adapt to the box size
37 box.SetHintMin(sz); 37 win.SetContent(ebox);
38 38 });
39 // Set the box as the content for the window
40 // The window size will adapt to the box size
41 win.SetContent(box);
42 39
43 // Create a text label widget 40 // Create a text label widget
44 efl.ui.IText text = new efl.ui.Text(box); 41 new efl.ui.Text(box, (efl.ui.IText etext) => {
45 // Set its content and customize it 42 // Set its content and customize it
46 text.SetText("Hello World. This is an Efl.Ui application!"); 43 etext.SetText("Hello World. This is an Efl.Ui application!");
47 text.SetSelectionAllowed(false); 44 etext.SetSelectionAllowed(false);
48 text.SetHintWeight(1.0, 0.9); 45 etext.SetHintWeight(1.0, 0.9);
49 text.SetHintAlign(0.5, 0.5); 46 etext.SetHintAlign(0.5, 0.5);
50 47 // Add the text to the box container
51 // Add the text to the box container 48 box.DoPack(etext);
52 box.DoPack(text); 49 });
53 50
54 // Create a button widget 51 // Create a button widget
55 efl.ui.IButton button = new efl.ui.Button(box); 52 new efl.ui.Button(box, (efl.ui.IButton ebutton) => {
56 // Customize it 53 // Customize it
57 button.SetText("Quit"); 54 ebutton.SetText("Quit");
58 button.SetHintWeight(1.0, 0.1); 55 ebutton.SetHintWeight(1.0, 0.1);
59 56 // Set the method to be called when the button is pressed
60 // Set the method to be called when the button is pressed 57 ebutton.ClickedEvt += QuitCb;
61 button.ClickedEvt += QuitCb; 58 // Add the button to the box container
62 59 box.DoPack(ebutton);
63 // Add the button to the box container 60 });
64 box.DoPack(button);
65 61
66 // Start the EFL main loop 62 // Start the EFL main loop
67 efl.ui.Config.Run(); 63 efl.ui.Config.Run();