summaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2018-08-22 08:07:53 -0700
committerapache <apache@e5-web1.enlightenment.org>2018-08-22 08:07:53 -0700
commit9f298a3b263da75a77fdba6c0ce08bfd01562518 (patch)
treede402531685c05d844080d617be7d6c44d7af51d /pages
parent6e79e6af6b92564baa6b8d7b719d75abeed481e9 (diff)
Wiki page start.md changed with summary [Removed example and restructured] by Xavi Artigas
Diffstat (limited to 'pages')
-rw-r--r--pages/develop/setup/csharp/start.md.txt166
1 files changed, 25 insertions, 141 deletions
diff --git a/pages/develop/setup/csharp/start.md.txt b/pages/develop/setup/csharp/start.md.txt
index 6b4584fa9..2ef3ced6b 100644
--- a/pages/develop/setup/csharp/start.md.txt
+++ b/pages/develop/setup/csharp/start.md.txt
@@ -4,32 +4,28 @@
4 4
5# Setting Up a C# Development Environment # 5# Setting Up a C# Development Environment #
6 6
7This page shows how to compile and install the Enlightenment Foundation Libraries (EFL) with C# bindings support, and some examples of how to use it. 7This page shows how to compile and install the Enlightenment Foundation Libraries (EFL) with C# bindings support, and explains how to build and run applications using them.
8 8
9| | WARNING | | 9| | WARNING | |
10| --- | ------- | --- | 10| --- | ------- | --- |
11| ![NOTE](/_media/note-important.png) | **The C# bindings are currently in BETA state**<br>They should only be used for experimenting and **NOT** for any product development. | ![NOTE](/_media/note-important.png) | 11| ![NOTE](/_media/note-important.png) | **The C# bindings are currently in BETA state**<br>They should only be used for experimenting and **NOT** for any product development. | ![NOTE](/_media/note-important.png) |
12 12
13## Getting Started ## 13## Prerequisites ##
14 14
15### Prerequisites ### 15* Before you start you may want to read about [how to compile the EFL](https://www.enlightenment.org/docs/distros/start).
16 16
17Before you start you may want to read about [how to compile the EFL](https://www.enlightenment.org/docs/distros/start). 17## Dependencies ##
18 18
19### Dependencies ### 19### On Linux ###
20
21#### On Linux ####
22 20
23You need a compatible version of [Mono](http://www.mono-project.com/download/stable) (5.0 or higher). 21You need a compatible version of [Mono](http://www.mono-project.com/download/stable) (5.0 or higher).
24 22
25> **NOTE:** 23> **NOTE:**
26> Currently the C# bindings do not work with Mono 4.x. 24> Currently the C# bindings do **NOT** work with Mono 4.x.
27 25
28The paths to the ``mcs`` compiler and to the ``mono`` application must be in the ``PATH`` environment variable before compiling. 26The paths to the ``mcs`` compiler and to the ``mono`` application must be in the ``PATH`` environment variable before compiling.
29 27
30Once all conditions are met proceed to [Compiling and Installing](#Compiling_and_Installing). 28### On Windows ###
31
32#### On Windows ####
33 29
34In 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). 30In 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).
35 31
@@ -47,11 +43,10 @@ If you used another installation path to Mono just adjust the paths used.
47Mono has its own version of some applications (like ``pkg-config``) which can take priority over the ones from MSYS2 and cause things to fail. 43Mono has its own version of some applications (like ``pkg-config``) which can take priority over the ones from MSYS2 and cause things to fail.
48 44
49Now you can use the MSYS2 console to compile, install and run EFL and your applications. 45Now you can use the MSYS2 console to compile, install and run EFL and your applications.
50Once all conditions are met proceed to [Compiling and Installing](#Compiling_and_Installing).
51 46
52## Compiling and Installing ## 47## Compiling and Installing EFL With C# Support ##
53 48
54In 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: 49In order to compile and install EFL with C# binding support, on both Windows and Linux, just compile the EFL like the respective guides explain, and add the argument ``--enable-csharp-bindings`` to the ``autogen.sh`` or ``configure`` command:
55 50
56```bash 51```bash
57./autogen.sh --enable-csharp-bindings #other arguments 52./autogen.sh --enable-csharp-bindings #other arguments
@@ -62,155 +57,44 @@ sudo make install
62> **NOTE:** 57> **NOTE:**
63> 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. 58> 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.
64> Usually, reading the error message and installing the missing package solves the problem. 59> Usually, reading the error message and installing the missing package solves the problem.
65> If you can not solve the problem by yourself, try [contacting the community](/contact). 60> If you cannot solve the problem by yourself, try [contacting the community](/contact).
66 61
67## Examples ## 62## Building EFL C# Applications ##
68
69Now that you can compile and install EFL with C# bindings lets see some code examples.
70
71### Button Example ###
72
73Let's start with a very simple example that just creates a window with a button and show how to compile it.
74The code will be explained afterwards.
75
76```csharp
77using System;
78
79public class Example
80{
81#if WIN32
82 [STAThreadAttribute()]
83#endif
84 public static void Main()
85 {
86 efl.All.Init(efl.Components.Ui);
87
88 efl.ui.IWin win = new efl.ui.Win(null);
89 win.SetText("Hello, World!");
90 win.SetAutohide(true);
91 win.SetSize(new eina.Size2D(240, 60));
92 win.SetVisible(true);
93
94 efl.ui.IButton btn = new efl.ui.Button(win);
95 btn.SetText("Good-Bye, World!");
96 btn.SetSize(new eina.Size2D(120, 30));
97 eina.Position2D pos;
98 pos.X = 60;
99 pos.Y = 15;
100 btn.SetPosition(pos);
101 btn.SetVisible(true);
102 btn.ClickedEvt += (object sender, EventArgs e) => {
103 efl.ui.Config.Exit();
104 };
105
106 efl.ui.Config.Run();
107
108 efl.All.Shutdown();
109 }
110}
111```
112 63
113#### Compiling and running #### 64With EFL installed, you can compile EFL applications using ``pkg-config`` to get the proper flags to use the C# bindings:
114 65
115If you have EFL installed you can compile the example using ``pkg-config`` to get the proper flags for using the C# bindings:
116```bash 66```bash
117mcs button_example_00.cs -out:button_example_00.exe `pkg-config --libs efl-mono` 67mcs your_app.cs -out:your_app.exe `pkg-config --libs efl-mono`
118``` 68```
119 69
120Otherwise, you have to point the library location manually, like this: 70Otherwise, you have to manually point the compiler to the location of the EFL C# bindings library ``libefl_mono.dll``, like this:
71
121```bash 72```bash
122mcs button_example_00.cs -out:button_example_00.exe -r:/home/my_user/efl/build/src/lib/efl_mono/libefl_mono.dll 73mcs your_app.cs -out:your_app.exe -r:/home/my_user/efl/build/src/lib/efl_mono/libefl_mono.dll
123``` 74```
124 75
125To 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`` . 76## Running EFL C# Applications ##
126In both cases, you can use ``pkg-config`` to get the right paths. 77
78To run your application you can either copy the EFL C# bindings library ``libefl_mono.dll`` to your application folder or set the ``MONO_PATH`` environment variable and then execute it using ``mono``. In both cases, you can use ``pkg-config`` to get the right paths.
127 79
128Example copying the library: 80Example copying the library:
81
129```bash 82```bash
130cp `pkg-config --variable=Libraries efl-mono` . 83cp `pkg-config --variable=Libraries efl-mono` .
131mono button_example_00.exe 84mono button_example_00.exe
132``` 85```
133 86
134Example setting ``MONO_PATH``: 87Example setting ``MONO_PATH``:
88
135```bash 89```bash
136export MONO_PATH=`pkg-config --variable=assemblies_dir efl-mono` 90export MONO_PATH=`pkg-config --variable=assemblies_dir efl-mono`
137mono button_example_00.exe 91mono button_example_00.exe
138``` 92```
139 93
140Note 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: 94Note 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:
95
141```bash 96```bash
142export PKG_CONFIG_PATH=/opt/my_install_prefix/lib/pkgconfig 97export PKG_CONFIG_PATH=/opt/my_install_prefix/lib/pkgconfig
143export LD_LIBRARY_PATH=/opt/my_install_prefix/lib 98export LD_LIBRARY_PATH=/opt/my_install_prefix/lib
144``` 99```
145 100Try the [Hello World](/develop/tutorials/csharp/hello-world-cs.md) tutorial now to verify that everything works as expected. \ No newline at end of file
146#### Explaining the code ####
147
148First, we start with a basic class structure to define our ``Main`` entry point:
149```csharp
150using System;
151
152public class Example
153{
154#if WIN32
155 [STAThreadAttribute()]
156#endif
157 public static void Main()
158 {
159 // <code goes here>
160 }
161}
162```
163> **NOTE:**
164> The ``STAThreadAttribute`` is currently necessary in Windows systems because of limitations in ``ecore_win32``.
165> You can compile passing ``-define:WIN32`` to ``mcs`` to flag when you are compiling on a Windows system.
166
167Then we initialize EFL with Ui components enabled:
168```csharp
169 efl.All.Init(efl.Components.Ui);
170```
171
172And 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:
173```csharp
174 efl.ui.IWin win = new efl.ui.Win(null);
175 win.SetText("Hello, World!");
176 win.SetAutohide(true);
177 win.SetSize(new eina.Size2D(240, 60));
178 win.SetVisible(true);
179```
180
181Create 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:
182```csharp
183 efl.ui.IButton btn = new efl.ui.Button(win);
184 btn.SetText("Good-Bye, World!");
185 btn.SetSize(new eina.Size2D(120, 30));
186 eina.Position2D pos;
187 pos.X = 60;
188 pos.Y = 15;
189 btn.SetPosition(pos);
190 btn.SetVisible(true);
191```
192
193And then register a function to the button ``CLICKED`` event:
194```csharp
195 btn.ClickedEvt += (object sender, EventArgs e) => {
196 efl.ui.Config.Exit();
197 };
198```
199We use a simple lambda that calls a function to end the event loop, exiting ``efl.ui.Config.Run()`` and finishing the application.
200
201Once the setup is finished, we call:
202```csharp
203 efl.ui.Config.Run();
204```
205It starts the event loop and displays the application main window.
206
207After 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:
208```csharp
209 efl.All.Shutdown();
210```
211
212And this concludes the basic button example.
213
214### Efl.Ui.List and Efl.Model Example ###
215
216Coming soon. \ No newline at end of file