summaryrefslogtreecommitdiff
path: root/pages/develop/tutorials
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2019-01-23 09:02:32 -0800
committerapache <apache@e5-web1.enlightenment.org>2019-01-23 09:02:32 -0800
commiteb28f017907bc7c41ef431041af040112e58db7a (patch)
tree8c0f110d00e33852bde9e9287cbfe16ac04a19e9 /pages/develop/tutorials
parente6ec969e5024bf52e9aa516f4f02b7938b754951 (diff)
Wiki page hello-world-cs.md changed with summary [Adapt to latest EFL# syntax] by Xavi Artigas
Diffstat (limited to 'pages/develop/tutorials')
-rw-r--r--pages/develop/tutorials/csharp/hello-world-cs.md.txt74
1 files changed, 32 insertions, 42 deletions
diff --git a/pages/develop/tutorials/csharp/hello-world-cs.md.txt b/pages/develop/tutorials/csharp/hello-world-cs.md.txt
index e858e8cf8..f91eb5293 100644
--- a/pages/develop/tutorials/csharp/hello-world-cs.md.txt
+++ b/pages/develop/tutorials/csharp/hello-world-cs.md.txt
@@ -30,25 +30,24 @@ public class Example
30 public static void Main() 30 public static void Main()
31 { 31 {
32 // Initialize EFL and all UI components 32 // Initialize EFL and all UI components
33 efl.All.Init(efl.Components.Ui); 33 Efl.All.Init(Efl.Components.Ui);
34 34
35 // Create a window and initialize it 35 // Create a window and initialize it
36 efl.ui.IWin win = new efl.ui.Win(efl.App.GetLoopMain(), (efl.ui.IWin ewin) => { 36 Efl.Ui.Win win = new Efl.Ui.Win(Efl.App.AppMain);
37 // Set the window's title 37 // Set the window's title
38 ewin.SetText("Hello World"); 38 win.SetText("Hello World");
39 // Request that the window is automatically hidden when the "close" 39 // Request that the window is automatically hidden when the "close"
40 // button is pressed 40 // button is pressed
41 ewin.SetAutohide(true); 41 win.SetAutohide(true);
42 });
43 // Window size must be explicitly set, otherwise it will be invisible 42 // Window size must be explicitly set, otherwise it will be invisible
44 // due to its lack of content. 43 // due to its lack of content.
45 win.SetSize(new eina.Size2D(360, 240)); 44 win.SetSize(new Eina.Size2D(360, 240));
46 45
47 // Start the EFL main loop 46 // Start the EFL main loop
48 efl.ui.Config.Run(); 47 Efl.Ui.Config.Run();
49 48
50 // Shutdown EFL 49 // Shutdown EFL
51 efl.All.Shutdown(); 50 Efl.All.Shutdown();
52 } 51 }
53} 52}
54``` 53```
@@ -83,51 +82,45 @@ public class Example
83 82
84### EFL Initialization ### 83### EFL Initialization ###
85 84
86EFL is initialized with the `efl.All.Init()` method: 85EFL is initialized with the `Efl.All.Init()` method:
87 86
88```csharp 87```csharp
89 // Initialize EFL and all UI components 88 // Initialize EFL and all UI components
90 efl.All.Init(efl.Components.Ui); 89 Efl.All.Init(Efl.Components.Ui);
91``` 90```
92 91
93It accepts a parameter specifying which EFL components your app will require. This enables faster boot times and better resource usage by not loading and starting unnecessary components. 92It accepts a parameter specifying which EFL components your app will require. This enables faster boot times and better resource usage by not loading and starting unnecessary components.
94 93
95The only currently available options are `efl.Components.Basic` and `efl.Components.Ui`. When not specified, `Basic` is assumed. 94The only currently available options are `Efl.Components.Basic` and `Efl.Components.Ui`. When not specified, `Basic` is assumed.
96 95
97### Creating the Window ### 96### Creating the Window ###
98 97
99All EFL objects, like Windows, Widgets or Timers, are created using the standard `new` operator, for example: 98All EFL objects, like Windows, Widgets or Timers, are created using the standard `new` operator, for example:
100 99
101```csharp 100```csharp
102var win = new efl.ui.Win(); 101Efl.Ui.Win win = new Efl.Ui.Win();
103``` 102```
104 103
105However, EFL object constructors have two optional parameters which are worth knowing: 104However, EFL object constructors may have additional optional parameters. The first one, `parent`, is always available: Any EFL object can be the child of another EFL object (its parent). Parents will take care of disposing of all their children upon destruction, greatly simplifying object life-cycle management.
106
107* `parent`: Any EFL object can be the child of another EFL object (its parent). Parents will take care of disposing of all their children upon destruction, greatly simplifying object lifecycle management.
108* `initialization method`: This is a delegate method accepting an object of the class being instantiated (see the example below). This method will be called during construction to allow you to customize the EFL object being created.
109
110 The advantage over first creating and then customizing the object is that, in most cases, you won't even need to keep the object in a variable: just create it with a parent, customize it, and forget about it.
111 105
112In the tutorial code: 106In the tutorial code:
113 107
114```csharp 108```csharp
115 // Create a window and initialize it 109 // Create a window and initialize it
116 efl.ui.IWin win = new efl.ui.Win(efl.App.GetLoopMain(), (efl.ui.IWin ewin) => { 110 Efl.Ui.Win win = new Efl.Ui.Win(Efl.App.AppMain);
117 // Set the window's title 111 // Set the window's title
118 ewin.SetText("Hello World"); 112 win.SetText("Hello World");
119 // Request that the window is automatically hidden when the "close" 113 // Request that the window is automatically hidden when the "close"
120 // button is pressed 114 // button is pressed
121 ewin.SetAutohide(true); 115 win.SetAutohide(true);
122 });
123``` 116```
124 117
125Observe how the window is created as a child of `efl.App.GetLoopMain()`, the application's main loop. This ensures that the window will receive all messages coming from the application. 118Observe how the window is created as a child of `Efl.App.AppMain`, the application's main loop. This ensures that the window will receive all messages coming from the application.
126 119
127Also, note the initialization method, a lambda function which: 120Also, note the further customization of the Window object:
128 121
129* Sets the window title to `Hello World`. 122* The window title is set to `Hello World`.
130* Sets the `autohide` flag to true. This means that the window will automatically be hidden when the user closes it. The default behavior for an app when all its windows are hidden is to quit. 123* The `autohide` flag is set to true. This means that the window will automatically be hidden when the user closes it. The default behavior for an app when all its windows are hidden is to quit.
131 124
132### The Window Size ### 125### The Window Size ###
133 126
@@ -138,19 +131,16 @@ The next tutorial adds some content to the window, but meanwhile, you can manual
138```csharp 131```csharp
139 // Window size must be explicitly set, otherwise it will be invisible 132 // Window size must be explicitly set, otherwise it will be invisible
140 // due to its lack of content. 133 // due to its lack of content.
141 win.SetSize(new eina.Size2D(360, 240)); 134 win.SetSize(new Eina.Size2D(360, 240));
142``` 135```
143 136
144> **NOTE:**
145> You could have done this in the initialization method described above, but setting the size of a window during its construction has some issues at this moment (See [T7343](https://phab.enlightenment.org/T7343)).
146
147### Starting Up the User Interface ### 137### Starting Up the User Interface ###
148 138
149Now that all the required EFL objects have been created (only a window, actually), it's time to relinquish control to EFL. 139Now that all the required EFL objects have been created (only a window, actually), it's time to relinquish control to EFL.
150 140
151```csharp 141```csharp
152 // Start the EFL main loop 142 // Start the EFL main loop
153 efl.ui.Config.Run(); 143 Efl.Ui.Config.Run();
154``` 144```
155 145
156This method does not return until EFL exits. In any application you will set callback methods that EFL will use to inform you of some events, and you will plug more code on those methods. 146This method does not return until EFL exits. In any application you will set callback methods that EFL will use to inform you of some events, and you will plug more code on those methods.
@@ -161,7 +151,7 @@ The following tutorials show how to do that. For this one, the only remaining th
161 151
162```csharp 152```csharp
163 // Shutdown EFL 153 // Shutdown EFL
164 efl.All.Shutdown(); 154 Efl.All.Shutdown();
165``` 155```
166 156
167Always remember to shut down EFL to close windows, network connections and free resources. 157Always remember to shut down EFL to close windows, network connections and free resources.
@@ -170,10 +160,10 @@ Always remember to shut down EFL to close windows, network connections and free
170 160
171In this tutorial you have learned: 161In this tutorial you have learned:
172 162
173* How to properly initialize and shutdown the EFL library with `efl.All.Init()` and `efl.All.Shutdown()`. 163* How to properly initialize and shutdown the EFL library with `Efl.All.Init()` and `Efl.All.Shutdown()`.
174* How to create and initialize EFL objects using `new` and `initialization methods`. 164* How to create and initialize EFL objects using `new`.
175* How to instantiate an EFL window and customize it using the `efl.ui.Win` class. 165* How to instantiate an EFL window and customize it using the `Efl.Ui.Win` class.
176* How to start the UI by giving control to EFL with `efl.ui.Config.Run()`. 166* How to start the UI by giving control to EFL with `Efl.Ui.Config.Run()`.
177 167
178The following tutorial adds some text and a button to the UI, and shows how to react to a button press. 168The following tutorial adds some text and a button to the UI, and shows how to react to a button press.
179 169