summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2017-12-13 01:51:48 -0300
committerFelipe Magno de Almeida <felipe@expertisesolutions.com.br>2017-12-19 17:51:51 -0200
commit8f14f1610eb28ae961d453b8efdb91035c8d4777 (patch)
treedfae0d29a2571e19a80fc54f4155872d352b7c3e
parent98aa1a4eb129278fb1fb23f8db4145a40e5b3abf (diff)
examples: Add C# buttons/popup example.
Diffstat (limited to '')
-rw-r--r--src/Makefile_Efl_Mono.am36
-rw-r--r--src/examples/elementary/Makefile.am27
-rw-r--r--src/examples/elementary/efl_ui_unit_converter.cs152
3 files changed, 204 insertions, 11 deletions
diff --git a/src/Makefile_Efl_Mono.am b/src/Makefile_Efl_Mono.am
index 4715fff4c6..5b2f993d22 100644
--- a/src/Makefile_Efl_Mono.am
+++ b/src/Makefile_Efl_Mono.am
@@ -194,6 +194,16 @@ lib/efl_mono/libefl_mono.dll: $(efl_mono_files_dist) lib/efl_mono/$(am__dirstamp
194 @rm -f lib/efl_mono/libefl_mono.dll 194 @rm -f lib/efl_mono/libefl_mono.dll
195 $(AM_V_MCS) $(MCS) $(MCS_FLAGS) -out:$@ -t:library $(filter %.cs, $(^)) 195 $(AM_V_MCS) $(MCS) $(MCS_FLAGS) -out:$@ -t:library $(filter %.cs, $(^))
196 196
197lib/efl_mono/libefl_mono.dll.config:
198 echo "<configuration>" > $@
199 echo " <dllmap dll=\"eina\" target=\"$(abs_top_builddir)/src/lib/eina/.libs/libeina.so\"/>" >> $@
200 echo " <dllmap dll=\"ecore\" target=\"$(abs_top_builddir)/src/lib/ecore/.libs/libecore.so\"/>" >> $@
201 echo " <dllmap dll=\"eo\" target=\"$(abs_top_builddir)/src/lib/eo/.libs/libeo.so\"/>" >> $@
202 echo " <dllmap dll=\"evas\" target=\"$(abs_top_builddir)/src/lib/evas/.libs/libevas.so\"/>" >> $@
203 echo " <dllmap dll=\"eldbus\" target=\"$(abs_top_builddir)/src/lib/eldbus/.libs/libeldbus.so\"/>" >> $@
204 echo " <dllmap dll=\"elementary\" target=\"$(abs_top_builddir)/src/lib/elementary/.libs/libelementary.so\"/>" >> $@
205 echo "</configuration>" >> $@
206
197if HAVE_WIN32 207if HAVE_WIN32
198efl_mono_dll_dest = $(DESTDIR)$(bindir) 208efl_mono_dll_dest = $(DESTDIR)$(bindir)
199else 209else
@@ -348,6 +358,16 @@ tests/efl_mono/libefl_mono_test.dll: $(efl_mono_test_eolian_mono_files) tests/ef
348 @rm -f tests/efl_mono/libefl_mono_test.dll 358 @rm -f tests/efl_mono/libefl_mono_test.dll
349 $(AM_V_MCS) $(MCS) $(MCS_FLAGS) -r:$(abs_builddir)/lib/efl_mono/libefl_mono.dll -out:$@ -t:library $(filter %.cs, $(^)) 359 $(AM_V_MCS) $(MCS) $(MCS_FLAGS) -r:$(abs_builddir)/lib/efl_mono/libefl_mono.dll -out:$@ -t:library $(filter %.cs, $(^))
350 360
361tests/efl_mono/efl_mono$(EXEEXT).config:
362 echo "<configuration>" > $@
363 echo " <dllmap dll=\"eina\" target=\"$(abs_top_builddir)/src/lib/eina/.libs/libeina.so\"/>" >> $@
364 echo " <dllmap dll=\"ecore\" target=\"$(abs_top_builddir)/src/lib/ecore/.libs/libecore.so\"/>" >> $@
365 echo " <dllmap dll=\"eo\" target=\"$(abs_top_builddir)/src/lib/eo/.libs/libeo.so\"/>" >> $@
366 echo " <dllmap dll=\"evas\" target=\"$(abs_top_builddir)/src/lib/evas/.libs/libevas.so\"/>" >> $@
367 echo " <dllmap dll=\"eldbus\" target=\"$(abs_top_builddir)/src/lib/eldbus/.libs/libeldbus.so\"/>" >> $@
368 echo " <dllmap dll=\"elementary\" target=\"$(abs_top_builddir)/src/lib/elementary/.libs/libelementary.so\"/>" >> $@
369 echo "</configuration>" >> $@
370
351# C Sharp test executable 371# C Sharp test executable
352AM_TESTS_ENVIRONMENT += MONO='mono'; export MONO; 372AM_TESTS_ENVIRONMENT += MONO='mono'; export MONO;
353AM_TESTS_ENVIRONMENT += MONO_BUILDPATH='$(abs_top_builddir)'; export MONO_BUILDPATH; 373AM_TESTS_ENVIRONMENT += MONO_BUILDPATH='$(abs_top_builddir)'; export MONO_BUILDPATH;
@@ -357,7 +377,6 @@ if HAVE_WIN32
357AM_TESTS_ENVIRONMENT += PATH='$(PATH):$(TEST_PATHS):$(WIN_ADD_TEST_PATHS)'; export PATH; 377AM_TESTS_ENVIRONMENT += PATH='$(PATH):$(TEST_PATHS):$(WIN_ADD_TEST_PATHS)'; export PATH;
358else 378else
359AM_TESTS_ENVIRONMENT += LD_LIBRARY_PATH='$(LD_LIBRARY_PATH):$(TEST_PATHS)'; export LD_LIBRARY_PATH; 379AM_TESTS_ENVIRONMENT += LD_LIBRARY_PATH='$(LD_LIBRARY_PATH):$(TEST_PATHS)'; export LD_LIBRARY_PATH;
360endif
361 380
362check_PROGRAMS += tests/efl_mono/efl_mono 381check_PROGRAMS += tests/efl_mono/efl_mono
363TESTS += tests/efl_mono/mono_test_driver.sh 382TESTS += tests/efl_mono/mono_test_driver.sh
@@ -377,15 +396,7 @@ tests_efl_mono_efl_mono_SOURCES = \
377 tests/efl_mono/Value.cs \ 396 tests/efl_mono/Value.cs \
378 tests/efl_mono/ValueEolian.cs 397 tests/efl_mono/ValueEolian.cs
379 398
380lib/efl_mono/libefl_mono.dll.config: 399tests/efl_mono/efl_mono$(EXEEXT): $(tests_efl_mono_efl_mono_SOURCES) tests/efl_mono/$(am__dirstamp) lib/efl_mono/libefl_mono.dll tests/efl_mono/libefl_mono_test.dll tests/efl_mono/efl_mono$(EXEEXT).config
381 echo "<configuration>" > $@
382 echo " <dllmap dll=\"eina\" target=\"$(abs_top_builddir)/src/lib/eina/.libs/libeina.so\"/>" >> $@
383 echo " <dllmap dll=\"eo\" target=\"$(abs_top_builddir)/src/lib/eo/.libs/libeo.so\"/>" >> $@
384 echo " <dllmap dll=\"evas\" target=\"$(abs_top_builddir)/src/lib/evas/.libs/libevas.so\"/>" >> $@
385 echo " <dllmap dll=\"elementary\" target=\"$(abs_top_builddir)/src/lib/elementary/.libs/libelementary.so\"/>" >> $@
386 echo "</configuration>" >> $@
387
388tests/efl_mono/efl_mono$(EXEEXT): $(tests_efl_mono_efl_mono_SOURCES) tests/efl_mono/$(am__dirstamp) lib/efl_mono/libefl_mono.dll tests/efl_mono/libefl_mono_test.dll
389 @rm -f $@ 400 @rm -f $@
390 $(AM_V_MCS) $(MCS) $(MCS_FLAGS) -r:$(abs_top_builddir)/src/lib/efl_mono/libefl_mono.dll -r:$(abs_top_builddir)/src/tests/efl_mono/libefl_mono_test.dll -out:$@ $(filter %.cs, $(^)) 401 $(AM_V_MCS) $(MCS) $(MCS_FLAGS) -r:$(abs_top_builddir)/src/lib/efl_mono/libefl_mono.dll -r:$(abs_top_builddir)/src/tests/efl_mono/libefl_mono_test.dll -out:$@ $(filter %.cs, $(^))
391 402
@@ -395,5 +406,10 @@ tests/efl_mono/%.eo.cs: tests/efl_mono/%.eo $(_EOLIAN_MONO_DEP)
395 $(MKDIR_P) $(dir $@); \ 406 $(MKDIR_P) $(dir $@); \
396 $(EOLIAN_MONO) $(EOLIAN_FLAGS) $(EOLIAN_MONO_FLAGS) --dllimport "@DLIB_PREFIX_MONO@efl_mono_native_test@DLIB_SUFFIX_MONO@" -o $@ $(ALL_EO_REFS) $< 407 $(EOLIAN_MONO) $(EOLIAN_FLAGS) $(EOLIAN_MONO_FLAGS) --dllimport "@DLIB_PREFIX_MONO@efl_mono_native_test@DLIB_SUFFIX_MONO@" -o $@ $(ALL_EO_REFS) $<
397 408
409CLEANFILES += tests/efl_mono/libefl_mono_test.dll tests/efl_mono/test_testing.eo.cs tests/efl_mono/test_numberwrapper.eo.cs tests/efl_mono/test_testing.eo.c tests/efl_mono/test_numberwrapper.eo.c tests/efl_mono/test_testing.eo.h tests/efl_mono/test_numberwrapper.eo.h
410
411endif
412
413
398endif 414endif
399endif 415endif
diff --git a/src/examples/elementary/Makefile.am b/src/examples/elementary/Makefile.am
index 320d333125..22b6471edd 100644
--- a/src/examples/elementary/Makefile.am
+++ b/src/examples/elementary/Makefile.am
@@ -265,6 +265,30 @@ nodist_codegen_example_SOURCES = \
265codegen_example_generated.c \ 265codegen_example_generated.c \
266codegen_example_generated.h 266codegen_example_generated.h
267 267
268if HAVE_CSHARP
269
270if HAVE_WIN32
271MCS_FLAGS := $(MCS_FLAGS)
272MCS_FLAGS += -define:WIN32
273endif
274
275efl_ui_slider_mono_exe_SOURCES = \
276 efl_ui_slider_mono.cs
277
278efl_ui_slider_mono(EXEEXT): $(efl_ui_slider_mono_exe_SOURCES) $(am_dirstamp) $(top_builddir)/src/lib/efl_mono/libefl_mono.dll$(EXEEXT)
279 @rm -f efl_ui_slider_mono$(EXEEXT)
280 $(AM_V_MCS) $(MCS) $(MCS_FLAGS) -r:$(abs_top_builddir)/src/lib/efl_mono/libefl_mono.dll$(EXEEXT) -out:$@ $(filter %.cs, $(^))
281
282efl_ui_unit_converter_exe_SOURCES = \
283 efl_ui_unit_converter.cs
284
285efl_ui_unit_converter: $(efl_ui_unit_converter_exe_SOURCES) $(am_dirstamp) $(top_builddir)/src/lib/efl_mono/libefl_mono.dll
286 @rm -f efl_ui_unit_converter
287 $(AM_V_MCS) $(MCS) $(MCS_FLAGS) -r:$(abs_top_builddir)/src/lib/efl_mono/libefl_mono.dll -out:$@ $(filter %.cs, $(^))
288
289
290endif
291
268examples_PROGRAMS = \ 292examples_PROGRAMS = \
269actionslider_example_01 \ 293actionslider_example_01 \
270bg_example_01 \ 294bg_example_01 \
@@ -443,7 +467,8 @@ efl_ui_slider_mono$(EXEEXT): $(efl_ui_slider_mono_SOURCES) $(am_dirstamp) $(top_
443 $(AM_V_MCS) $(MCS) $(MCS_FLAGS) -r:$(abs_top_builddir)/src/lib/efl_mono/libefl_mono.dll -out:$@ $(filter %.cs, $(^)) 467 $(AM_V_MCS) $(MCS) $(MCS_FLAGS) -r:$(abs_top_builddir)/src/lib/efl_mono/libefl_mono.dll -out:$@ $(filter %.cs, $(^))
444 468
445examples_PROGRAMS += \ 469examples_PROGRAMS += \
446 efl_ui_slider_mono 470 efl_ui_slider_mono \
471 efl_ui_unit_converter
447 472
448endif 473endif
449 474
diff --git a/src/examples/elementary/efl_ui_unit_converter.cs b/src/examples/elementary/efl_ui_unit_converter.cs
new file mode 100644
index 0000000000..f167e68ca2
--- /dev/null
+++ b/src/examples/elementary/efl_ui_unit_converter.cs
@@ -0,0 +1,152 @@
1using System;
2
3public class Example
4{
5
6 private static double KMS_PER_MILE = 1.609344;
7
8 private static double KmsToMiles(double kms)
9 {
10 return kms / KMS_PER_MILE;
11 }
12 private static double MilesToKms(double miles)
13 {
14 return miles * KMS_PER_MILE;
15 }
16
17 private static void ShowErrorPopup(efl.ui.Win win, string message)
18 {
19 efl.ui.Popup_Alert popup = new efl.ui.Popup_AlertConcrete(win);
20 efl.ui.Text popup_text = new efl.ui.TextConcrete(popup);
21 popup_text.SetText($"Error: {message}");
22 popup.SetContent(popup_text);
23 popup.SetVisible(true);
24 popup.SetButton(efl.ui.popup_alert.Button.Positive, "Ok");
25 popup.SetSize(150, 30);
26 popup.CLICKED += (object sender, efl.ui.CLICKED_Args e) => {
27 popup.SetParent(null);
28 popup.Del();
29 };
30 }
31
32#if WIN32 // Passed to the C# compiler with -define:WIN32
33 // Mono on Windows by default uses multi-thread apartments for COM stuff while
34 // OLE - used by ecore win32 DnD requires single threading for COM.
35 [STAThreadAttribute()]
36#endif
37 public static void Main() {
38 efl.All.Init(efl.Components.Ui);
39
40 efl.ui.Win win = new efl.ui.WinConcrete(null);
41 win.SetText("C# Unit Converter");
42 win.SetAutohide(true);
43
44 efl.ui.Box_Flow box = new efl.ui.Box_FlowConcrete(win);
45 box.SetDirection(efl.ui.Dir.Horizontal);
46
47 efl.ui.Box_Flow miles_box = new efl.ui.Box_FlowConcrete(box);
48 miles_box.SetDirection(efl.ui.Dir.Down);
49
50 box.Pack(miles_box);
51
52 efl.ui.Text miles_label = new efl.ui.TextConcrete(miles_box);
53 miles_label.SetText("Miles:");
54 miles_label.SetSize(120, 30);
55 miles_label.SetVisible(true);
56
57 efl.ui.text.Editable miles_input = new efl.ui.text.EditableConcrete(miles_box);
58 miles_input.SetText("");
59 miles_input.SetScrollable(true);
60 miles_input.SetSize(120, 30);
61 miles_input.SetVisible(true);
62
63 efl.ui.Button miles_button = new efl.ui.ButtonConcrete(miles_box);
64 miles_button.SetText("To Km");
65 miles_button.SetSize(120, 30);
66 miles_button.SetVisible(true);
67
68 miles_box.Pack(miles_label);
69 miles_box.Pack(miles_input);
70 miles_box.Pack(miles_button);
71
72
73 efl.ui.Box_Flow kms_box = new efl.ui.Box_FlowConcrete(box);
74 kms_box.SetDirection(efl.ui.Dir.Down);
75
76 box.Pack(kms_box);
77
78 efl.ui.Text kms_label = new efl.ui.TextConcrete(kms_box);
79 kms_label.SetText("Kilometers:");
80 kms_label.SetSize(120, 30);
81 kms_label.SetVisible(true);
82
83 efl.ui.text.Editable kms_input = new efl.ui.text.EditableConcrete(kms_box);
84 kms_input.SetText("");
85 kms_input.SetScrollable(true);
86 kms_input.SetSize(120, 30);
87 kms_input.SetVisible(true);
88
89 efl.ui.Button kms_button = new efl.ui.ButtonConcrete(kms_box);
90 kms_button.SetText("To Miles");
91 kms_button.SetSize(120, 30);
92 kms_button.SetVisible(true);
93
94 kms_box.Pack(kms_label);
95 kms_box.Pack(kms_input);
96 kms_box.Pack(kms_button);
97
98 kms_button.CLICKED += (object sender, EventArgs e) => {
99 try
100 {
101 string text = kms_input.GetText();
102 Console.WriteLine("Text is [{0}]", text);
103 double val = double.Parse(text);
104 miles_input.SetText(String.Format("{0:f3}", KmsToMiles(val)));
105 kms_input.SetFocus(true);
106 }
107 catch (FormatException ex)
108 {
109 Console.WriteLine("Exception {0} caught", ex);
110 ShowErrorPopup(win, "Invalid number");
111 }
112 };
113
114 miles_button.CLICKED += (object sender, EventArgs e) => {
115 try
116 {
117 string text = miles_input.GetText();
118 Console.WriteLine("Text is [{0}]", text);
119 double val = double.Parse(text);
120 kms_input.SetText(String.Format("{0:f3}", MilesToKms(val)));
121 miles_input.SetFocus(true);
122 }
123 catch (FormatException ex)
124 {
125 Console.WriteLine("Exception {0} cautght", ex);
126 ShowErrorPopup(win, "Invalid number");
127 }
128 };
129
130 kms_box.SetVisible(true);
131 miles_box.SetVisible(true);
132
133 eina.Position2D pos;
134
135 pos.X = 20;
136 pos.Y = 30;
137 box.SetPosition(pos);
138 box.SetVisible(true);
139
140 pos.X = 200;
141 pos.Y = 200;
142 win.SetPosition(pos);
143
144 win.SetSize(400,120);
145 win.SetVisible(true);
146
147 efl.ui.Config.Run();
148
149 efl.All.Shutdown();
150 }
151
152}