diff --git a/tutorial/csharp/focus/meson.build b/tutorial/csharp/focus/meson.build new file mode 100644 index 00000000..5959602d --- /dev/null +++ b/tutorial/csharp/focus/meson.build @@ -0,0 +1,9 @@ +project( + 'efl-example-focus', 'cs', + version : '0.0.1', + meson_version : '>= 0.38.0') + +efl_mono = dependency('efl-mono', version : '>=1.20.99') +efl_mono_libs = efl_mono.get_pkgconfig_variable('mono_libs') + +subdir('src') diff --git a/tutorial/csharp/focus/src/focus_main.cs b/tutorial/csharp/focus/src/focus_main.cs new file mode 100644 index 00000000..c8e34f87 --- /dev/null +++ b/tutorial/csharp/focus/src/focus_main.cs @@ -0,0 +1,70 @@ +using System; + +public class Example +{ + public static void QuitCb(object sender, EventArgs e) + { + Console.WriteLine("Clicked Quit"); + efl.ui.Config.Exit(); + } + + public static void AboutCb(object sender, EventArgs e) + { + Console.WriteLine("Clicked About"); + } + + public static void FocusChangedCb(object sender, EventArgs e) + { + Console.WriteLine($"Focus for object {((efl.Text)sender).GetText()} changed to {((efl.ui.Widget)sender).GetFocus()}"); + } + + public static void Main() + { + efl.All.Init(efl.Components.Ui); + + efl.ui.Win win = new efl.ui.WinConcrete(null, (efl.ui.Win ewin) => { + ewin.SetWinType(efl.ui.win.Type.Basic); + ewin.SetText("Hello World"); + ewin.SetAutohide(true); + }); + win.HIDE += QuitCb; + + efl.ui.Box box = new efl.ui.BoxConcrete(win); + eina.Size2D sz; + sz.W = 360; + sz.H = 240; + box.SetHintMin(sz); + win.SetContent(box); + + efl.ui.Text text = new efl.ui.TextConcrete(box); + text.SetText("Label"); + text.SetEditable(false); + text.FOCUS_CHANGED += FocusChangedCb; + box.Pack(text); + + efl.ui.Box hbox = new efl.ui.BoxConcrete(box); + hbox.SetDirection(efl.ui.Dir.Horizontal); + hbox.SetHintWeight(1.0, 0.1); + box.Pack(hbox); + + efl.ui.Button about = new efl.ui.ButtonConcrete(hbox); + about.SetText("About"); + about.FOCUS_CHANGED += FocusChangedCb; + about.CLICKED += AboutCb; + hbox.Pack(about); + + efl.ui.Button quit = new efl.ui.ButtonConcrete(hbox); + quit.SetText("Quit"); + quit.FOCUS_CHANGED += FocusChangedCb; + quit.CLICKED += QuitCb; + hbox.Pack(quit); + + // TODO: Create public references to classes + // efl_ui_focus_util_focus(EFL_UI_FOCUS_UTIL_CLASS, about); + + efl.ui.Config.Run(); + + efl.All.Shutdown(); + } +} + diff --git a/tutorial/csharp/focus/src/meson.build b/tutorial/csharp/focus/src/meson.build new file mode 100644 index 00000000..9d1e9fcd --- /dev/null +++ b/tutorial/csharp/focus/src/meson.build @@ -0,0 +1,11 @@ +src = files([ + 'focus_main.cs', +]) + +deps = [efl_mono] + +executable('efl_example_focus', src, + dependencies : deps, + cs_args : efl_mono_libs, + install : true +) diff --git a/tutorial/csharp/hello-gui/meson.build b/tutorial/csharp/hello-gui/meson.build new file mode 100644 index 00000000..14e84767 --- /dev/null +++ b/tutorial/csharp/hello-gui/meson.build @@ -0,0 +1,10 @@ +project( + 'efl-example-gui', 'cs', + version : '0.0.1', + meson_version : '>= 0.38.0') + +efl_mono = dependency('efl-mono', version : '>=1.20.99') +efl_mono_libs = efl_mono.get_pkgconfig_variable('mono_libs') + +subdir('src') + diff --git a/tutorial/csharp/hello-gui/src/gui_main.cs b/tutorial/csharp/hello-gui/src/gui_main.cs new file mode 100644 index 00000000..c5aef560 --- /dev/null +++ b/tutorial/csharp/hello-gui/src/gui_main.cs @@ -0,0 +1,53 @@ +using System; + +public class Example +{ + public static void QuitCb(object sender, EventArgs e) + { + efl.ui.Config.Exit(); + } + + public static void Main() + { + efl.All.Init(efl.Components.Ui); + + efl.ui.Win win = new efl.ui.WinConcrete(null, (efl.ui.Win ewin) => { + ewin.SetWinType(efl.ui.win.Type.Basic); + ewin.SetText("Hello World"); + ewin.SetAutohide(true); + }); + + // when the user clicks "close" on a window there is a request to hide + win.HIDE += QuitCb; + + efl.ui.Box box = new efl.ui.BoxConcrete(win); + eina.Size2D sz; + sz.W = 360; + sz.H = 240; + box.SetHintMin(sz); + + win.SetContent(box); + + efl.ui.Text text = new efl.ui.TextConcrete(box); + // text.SetMarkup("Hello World.
This is an Efl.Ui application!"); // TODO: Correct .eo inheritance + text.SetText("Hello World. This is an Efl.Ui application!"); + text.SetSelectionAllowed(false); + text.SetHintWeight(1.0, 0.9); + text.SetHintAlign(0.5, 0.5); + + box.Pack(text); + + efl.ui.Button button = new efl.ui.ButtonConcrete(box); + button.SetText("Quit"); + button.SetHintWeight(1.0, 0.1); + + button.CLICKED += QuitCb; + + box.Pack(button); + + efl.ui.Config.Run(); + + efl.All.Shutdown(); + } +} + diff --git a/tutorial/csharp/hello-gui/src/meson.build b/tutorial/csharp/hello-gui/src/meson.build new file mode 100644 index 00000000..ede76731 --- /dev/null +++ b/tutorial/csharp/hello-gui/src/meson.build @@ -0,0 +1,12 @@ +src = files([ + 'gui_main.cs', +]) + +deps = [efl_mono] + +executable('efl_example_gui', src, + dependencies : deps, + cs_args : efl_mono_libs, + install : true +) +