summaryrefslogtreecommitdiff
path: root/pages/develop/setup/csharp/start.md.txt
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2018-07-25 02:49:46 -0700
committerapache <apache@e5-web1.enlightenment.org>2018-07-25 02:49:46 -0700
commit791d9a776cbc96cbe2217a1e4d2c2cf5026cb6f3 (patch)
treeed2714f4613d3b8a85cf6c0cdc8cc9a81b7249c3 /pages/develop/setup/csharp/start.md.txt
parentb76549d4e62d47683d367a2805ee3306c1b1b645 (diff)
Wiki page start.md changed with summary [Converted DokuWiki to Markdown] by Xavi Artigas
Diffstat (limited to 'pages/develop/setup/csharp/start.md.txt')
-rw-r--r--pages/develop/setup/csharp/start.md.txt159
1 files changed, 72 insertions, 87 deletions
diff --git a/pages/develop/setup/csharp/start.md.txt b/pages/develop/setup/csharp/start.md.txt
index 104617af2..e06b51488 100644
--- a/pages/develop/setup/csharp/start.md.txt
+++ b/pages/develop/setup/csharp/start.md.txt
@@ -19,69 +19,60 @@ Before you start you may want to read about [how to compile the EFL](https://www
19 19
20#### On Linux #### 20#### On Linux ####
21 21
22You need a compatible version of [[http://www.mono-project.com/download/stable/|Mono]] (5.0 or higher). 22You need a compatible version of [Mono](http://www.mono-project.com/download/stable) (5.0 or higher).
23 23
24> **NOTE:** 24> **NOTE:**
25> Currently the C# bindings do not work with Mono 4.x. 25> Currently the C# bindings do not work with Mono 4.x.
26 26
27The paths to the ``mcs`` compiler and to the ``mono`` application must be in the ``PATH`` environment variable before compiling. 27The paths to the ``mcs`` compiler and to the ``mono`` application must be in the ``PATH`` environment variable before compiling.
28 28
29Once all conditions are met proceed to (Compilation)[#Compilation]. 29Once all conditions are met proceed to [Compiling and Installing](#Compiling_and_Installing).
30 30
31Ubunut 31#### On Windows ####
32 32
33== On Windows == 33In order to have EFL on a Windows environment we highly recommend following [this guide](https://phab.enlightenment.org/w/windows/) which accomplishes that using [win-builds](http://win-builds.org) and [MSYS2](http://www.msys2.org).
34 34
35In order to have EFL on a Windows environment we highly recommend following [[https://phab.enlightenment.org/w/windows/|this guide]] which accomplishes that using [[http://win-builds.org|win-builds]] and [[http://www.msys2.org/|MSYS2]]. 35You need a compatible version of [Mono](http://www.mono-project.com) (5.0 or higher).
36 36You can use Mono binaries installed directly to your Windows system (i.e. outside the MSYS2 environment), you just need to make sure that the paths to the ``mcs.exe`` compiler and to the ``mono.exe`` application are in the ``PATH`` environment variable in your MSYS2 terminal.
37You need a compatible version of [[http://www.mono-project.com|Mono]] (4.0 or higher). 37Using the default installation path, Mono binaries normally go in ``C:\Program Files\Mono`` so in MSYS2 you can point to the binaries using the path ``/c/Program Files/Mono/bin``.
38You can use Mono binaries installed directly to your Windows system (i.e. outside the MSYS2 environment), you just need to make sure that the paths to the ''mcs.exe'' compiler and to the ''mono.exe'' application are in the ''PATH'' environment variable in your MSYS2 terminal. 38You can also permanently set this in your ``/etc/profile`` in MSYS2 adding something like this at the end of the file:
39Using the default installation path, Mono binaries normally goes in ''C:\Program Files\Mono''; so in MSYS2 you can point to the binaries using the path ''/c/Program Files/Mono/bin''. 39```bash
40You can also permanently set this in your ''/etc/profile'' in MSYS2 adding something like this at the end of the file:
41<code bash>
42export PATH="$PATH:/c/Program Files/Mono/bin" 40export PATH="$PATH:/c/Program Files/Mono/bin"
43</code> 41```
44If you used another installation path to Mono just adjust the paths used. 42If you used another installation path to Mono just adjust the paths used.
45 43
46<note important> 44> **NOTE:**
47It is advisable to add the Mono path at the **end** of the ''PATH'' environment variable, like in the example above. 45> It is advisable to add the Mono path at the **end** of the ``PATH`` environment variable, like in the example above.
48Mono has its own version of some applications (like ''pkg-config'') which can take priority over the ones from MSYS2 and cause things to fail. 46Mono has its own version of some applications (like ``pkg-config``) which can take priority over the ones from MSYS2 and cause things to fail.
49</note>
50 47
51Now you can use the MSYS2 console to compile, install and run EFL and your applications. 48Now you can use the MSYS2 console to compile, install and run EFL and your applications.
52Once all conditions are met proceed to [[#Compilation]]. 49Once all conditions are met proceed to [Compiling and Installing](#Compiling_and_Installing).
50
51## Compiling and Installing ##
53 52
54=== Compiling and Installing === 53In order to compile and install EFL with C# binding support, on both Windows and Linux, just compile the EFL like the respective guides suggests, and add the argument ``--enable-csharp-bindings`` to the ``autogen.sh`` or ``configure`` command:
55 54
56In order to compile and install EFL with C# binding support, in both Windows and Linux just compile the EFL like the respective guide suggests, only add the argument ''--enable-csharp-bindings'' to the ''autogen.sh'' or ''configure'' command. 55```bash
57Like:
58<code bash>
59./autogen.sh --enable-csharp-bindings #other arguments 56./autogen.sh --enable-csharp-bindings #other arguments
60make -j4 57make -j4
61sudo make install 58sudo make install
62</code> 59```
63 60
64<note> 61> **NOTE:**
65It is known that some tutorials can get a bit outdated from time to time, causing the building process to fail, usually because of a missing dependency. 62> It is known that some portions of the code (typically the examples) can get a bit outdated from time to time, causing the building process to fail. The leading cause for this is a missing dependency.
66Normally reading the error message and installing the missing package solves the problem. 63> Usually, reading the error message and installing the missing package solves the problem.
67If you can not solve the problem by yourself, try [[/contact|contacting]] the community. 64> If you can not solve the problem by yourself, try [contacting the community](/contact).
68</note>
69 65
70==== Examples ==== 66## Examples ##
71 67
72Now that you can compile and install EFL with C# bindings lets see some code examples. 68Now that you can compile and install EFL with C# bindings lets see some code examples.
73 69
74=== Button Example === 70### Button Example ###
75
76Lets start with a very simple example that just creates a window with a button and show how to compile it.
77After, the code will be explained.
78 71
79<note tip> 72Let's start with a very simple example that just creates a window with a button and show how to compile it.
80You can find this example in ''<efl_source>/src/examples/elementary/button_example_00.cs'' 73The code will be explained afterwards.
81</note>
82 74
83The code: 75```csharp
84<code csharp>
85using System; 76using System;
86 77
87public class Example 78public class Example
@@ -96,13 +87,11 @@ public class Example
96 efl.ui.IWin win = new efl.ui.Win(null); 87 efl.ui.IWin win = new efl.ui.Win(null);
97 win.SetText("Hello, World!"); 88 win.SetText("Hello, World!");
98 win.SetAutohide(true); 89 win.SetAutohide(true);
99 //win.SetSize(240, 60);
100 win.SetSize(new eina.Size2D(240, 60)); 90 win.SetSize(new eina.Size2D(240, 60));
101 win.SetVisible(true); 91 win.SetVisible(true);
102 92
103 efl.ui.IButton btn = new efl.ui.Button(win); 93 efl.ui.IButton btn = new efl.ui.Button(win);
104 btn.SetText("Good-Bye, World!"); 94 btn.SetText("Good-Bye, World!");
105 //btn.SetSize(120, 30);
106 btn.SetSize(new eina.Size2D(120, 30)); 95 btn.SetSize(new eina.Size2D(120, 30));
107 eina.Position2D pos; 96 eina.Position2D pos;
108 pos.X = 60; 97 pos.X = 60;
@@ -118,46 +107,45 @@ public class Example
118 efl.All.Shutdown(); 107 efl.All.Shutdown();
119 } 108 }
120} 109}
121</code> 110```
122 111
123== Compiling and running == 112#### Compiling and running ####
124 113
125If you have EFL installed you can compile the example using ''pkg-config'' to get the proper flags for using the C# binding: 114If you have EFL installed you can compile the example using ``pkg-config`` to get the proper flags for using the C# bindings:
126<code bash> 115```bash
127mcs button_example_00.cs -out:button_example_00.exe `pkg-config --libs efl-mono` 116mcs button_example_00.cs -out:button_example_00.exe `pkg-config --libs efl-mono`
128</code> 117```
129 118
130Otherwise, you have to point the library location manually, like: 119Otherwise, you have to point the library location manually, like this:
131<code bash> 120```bash
132mcs button_example_00.cs -out:button_example_00.exe -r:/home/my_user/efl/build/src/lib/efl_mono/libefl_mono.dll 121mcs button_example_00.cs -out:button_example_00.exe -r:/home/my_user/efl/build/src/lib/efl_mono/libefl_mono.dll
133</code> 122```
134 123
135To run the application you can either copy the EFL C# binding library to your folder or set the ''MONO_PATH'' environment variable, them execute it using ''mono''. 124To run the application you can either copy the EFL C# bindings library to your folder or set the `` MONO_PATH`` environment variable and then execute it using ``mono`` .
136In both cases, you can use ''pkg-config'' to get the right paths. 125In both cases, you can use ``pkg-config`` to get the right paths.
137 126
138Example coping the library: 127Example copying the library:
139<code bash> 128```bash
140cp `pkg-config --variable=Libraries efl-mono` . 129cp `pkg-config --variable=Libraries efl-mono` .
141mono button_example_00.exe 130mono button_example_00.exe
142</code> 131```
143 132
144Example setting ''MONO_PATH'': 133Example setting ``MONO_PATH``:
145<code bash> 134```bash
146export MONO_PATH=`pkg-config --variable=assemblies_dir efl-mono` 135export MONO_PATH=`pkg-config --variable=assemblies_dir efl-mono`
147mono button_example_00.exe 136mono button_example_00.exe
148</code> 137```
149 138
150Note that if you installed EFL in a path that is not directly accessible to ''pkg-config'' or to your application you have to manually make it accessible someway, 139Note that if you installed EFL in a path that is not directly accessible to ``pkg-config`` or to your application you have to manually make it accessible somehow, for example setting proper environment variables before compiling and running:
151for example setting proper environment variables before compiling and running: 140```bash
152<code bash>
153export PKG_CONFIG_PATH=/opt/my_install_prefix/lib/pkgconfig 141export PKG_CONFIG_PATH=/opt/my_install_prefix/lib/pkgconfig
154export LD_LIBRARY_PATH=/opt/my_install_prefix/lib 142export LD_LIBRARY_PATH=/opt/my_install_prefix/lib
155</code> 143```
156 144
157== Explaining the code == 145#### Explaining the code ####
158 146
159First, we start with a basic class structure to define our ''Main'' entry point: 147First, we start with a basic class structure to define our ``Main`` entry point:
160<code csharp> 148```csharp
161using System; 149using System;
162 150
163public class Example 151public class Example
@@ -170,61 +158,58 @@ public class Example
170 // <code goes here> 158 // <code goes here>
171 } 159 }
172} 160}
173</code> 161```
174<note important> 162> **NOTE:**
175The ''STAThreadAttribute'' is currently necessary in Windows systems because of limitations in ''ecore_win32''. 163> The ``STAThreadAttribute`` is currently necessary in Windows systems because of limitations in ``ecore_win32``.
176You can compile passing ''-define:WIN32'' to ''mcs'' to flag when you are compiling on a Windows system. 164> You can compile passing ``-define:WIN32`` to ``mcs`` to flag when you are compiling on a Windows system.
177</note>
178 165
179Then we initialize EFL with Ui components enabled: 166Then we initialize EFL with Ui components enabled:
180<code csharp> 167```csharp
181 efl.All.Init(efl.Components.Ui); 168 efl.All.Init(efl.Components.Ui);
182</code> 169```
183 170
184And create a new Window with auto-hide (the window is automatically hidden when the close button is clicked), set its title, give it a dimension and turn it visible: 171And create a new Window with auto-hide (the window is automatically hidden when the close button is clicked), set its title, give it a dimension and turn it visible:
185<code csharp> 172```csharp
186 efl.ui.IWin win = new efl.ui.Win(null); 173 efl.ui.IWin win = new efl.ui.Win(null);
187 win.SetText("Hello, World!"); 174 win.SetText("Hello, World!");
188 win.SetAutohide(true); 175 win.SetAutohide(true);
189 //win.SetSize(240, 60);
190 win.SetSize(new eina.Size2D(240, 60)); 176 win.SetSize(new eina.Size2D(240, 60));
191 win.SetVisible(true); 177 win.SetVisible(true);
192</code> 178```
193 179
194Create a new Button (passing the newly created window as the parent), set new label text to the button, give it a dimension and position and turn it visible: 180Create a new Button (passing the newly created window as the parent), set new label text to the button, give it a dimension and position and turn it visible:
195<code csharp> 181```csharp
196 efl.ui.IButton btn = new efl.ui.Button(win); 182 efl.ui.IButton btn = new efl.ui.Button(win);
197 btn.SetText("Good-Bye, World!"); 183 btn.SetText("Good-Bye, World!");
198 //btn.SetSize(120, 30);
199 btn.SetSize(new eina.Size2D(120, 30)); 184 btn.SetSize(new eina.Size2D(120, 30));
200 eina.Position2D pos; 185 eina.Position2D pos;
201 pos.X = 60; 186 pos.X = 60;
202 pos.Y = 15; 187 pos.Y = 15;
203 btn.SetPosition(pos); 188 btn.SetPosition(pos);
204 btn.SetVisible(true); 189 btn.SetVisible(true);
205</code> 190```
206 191
207And then register a function to the button ''CLICKED'' event: 192And then register a function to the button ``CLICKED`` event:
208<code csharp> 193```csharp
209 btn.ClickedEvt += (object sender, EventArgs e) => { 194 btn.ClickedEvt += (object sender, EventArgs e) => {
210 efl.ui.Config.Exit(); 195 efl.ui.Config.Exit();
211 }; 196 };
212</code> 197```
213We use a simple lambda that calls a function to end the event loop, exiting ''efl.ui.Config.Run()'' and finishing the application. 198We use a simple lambda that calls a function to end the event loop, exiting ``efl.ui.Config.Run()`` and finishing the application.
214 199
215Once the setup is finished, we call: 200Once the setup is finished, we call:
216<code csharp> 201```csharp
217 efl.ui.Config.Run(); 202 efl.ui.Config.Run();
218</code> 203```
219It starts the event loop and display the application main window. 204It starts the event loop and displays the application main window.
220 205
221After the event loop is finished (when closing the last window or by calling ''efl.ui.Config.Exit()'') we shut down the EFL components and let the application end: 206After the event loop is finished (when closing the last window or by calling ``efl.ui.Config.Exit()``) we shut down the EFL components and let the application end:
222<code csharp> 207```csharp
223 efl.All.Shutdown(); 208 efl.All.Shutdown();
224</code> 209```
225 210
226And this concludes the basic button example. 211And this concludes the basic button example.
227 212
228=== Efl.Ui.List and Efl.Model Example === 213### Efl.Ui.List and Efl.Model Example ###
229 214
230WIP \ No newline at end of file 215Coming soon. \ No newline at end of file