vitorsousa pushed a commit to branch master.

http://git.enlightenment.org/tools/examples.git/commit/?id=f22bd3aa1f4106acab3a51517d552fc2c79bcd6c

commit f22bd3aa1f4106acab3a51517d552fc2c79bcd6c
Author: Vitor Sousa <vitorsousasi...@gmail.com>
Date:   Mon Feb 19 16:19:01 2018 -0300

    ui_mono: add ui_content reference example for C#
---
 reference/csharp/ui/src/meson.build     |   7 ++
 reference/csharp/ui/src/ui_container.cs | 112 ++++++++++++++++++++++++++++++++
 2 files changed, 119 insertions(+)

diff --git a/reference/csharp/ui/src/meson.build 
b/reference/csharp/ui/src/meson.build
index 3adaecf..a975e0f 100644
--- a/reference/csharp/ui/src/meson.build
+++ b/reference/csharp/ui/src/meson.build
@@ -6,3 +6,10 @@ executable('efl_reference_ui_sizing',
   cs_args : efl_mono_libs,
   install : true
 )
+
+executable('efl_reference_ui_container',
+  files(['ui_container.cs']),
+  dependencies : deps,
+  cs_args : efl_mono_libs,
+  install : true
+)
diff --git a/reference/csharp/ui/src/ui_container.cs 
b/reference/csharp/ui/src/ui_container.cs
new file mode 100644
index 0000000..a36a805
--- /dev/null
+++ b/reference/csharp/ui/src/ui_container.cs
@@ -0,0 +1,112 @@
+/*
+ * Efl.UI container exmaples.
+ *
+ * Load and pack a selection of containers.
+ * Each has it's own unique layout and methods which are demonstrated below.
+ */
+
+using System;
+
+public class Example
+{
+    // quit the app, called if the user clicks the Quit button or the window 
is hidden
+    static void GuiQuitCb(object sender, EventArgs e)
+    {
+        efl.ui.Config.Exit();
+    }
+
+    // Load a simple table layout into the window
+    static efl.ui.Table SetupUiTable(efl.ui.Win win)
+    {
+        efl.ui.Table table = new efl.ui.TableConcrete(win);
+
+        table.SetTableColumns(2);
+        table.SetTableDirection(efl.ui.Dir.Right, efl.ui.Dir.Down);
+
+        efl.ui.Button button = new efl.ui.ButtonConcrete(win);
+        button.SetText("Long Button");
+
+        table.PackTable(button, 0, 2, 2, 1);
+
+        for (int i = 1; i <= 4; ++i)
+        {
+            efl.ui.Button btn = new efl.ui.ButtonConcrete(win);
+            btn.SetText($"Table {i}");
+            table.Pack(btn);
+        }
+
+        return table;
+    }
+
+    // Load some boxes - a horizontal one for the window layout and a vertical
+    // one to contain a flow
+    static efl.ui.Box SetupUiBoxes(efl.ui.Win win)
+    {
+        efl.ui.Box box = new efl.ui.BoxConcrete(win);
+        box.SetPackPadding(5, 0, true);
+
+        for (int i = 1; i <= 4; ++i)
+        {
+            efl.ui.Button button = new efl.ui.ButtonConcrete(win);
+            button.SetText($"Boxed {i}");
+            if (i == 2)
+            {
+                eina.Size2D sz;
+                sz.W = 100;
+                sz.H = 50;
+                button.SetHintMax(sz);
+            }
+            box.Pack(button);
+        }
+
+        return box;
+    }
+
+    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);
+        });
+        eina.Size2D sz;
+        sz.W = 350;
+        sz.H = 250;
+        win.SetSize(sz);
+
+        // when the user clicks "close" on a window there is a request to hide
+        win.HIDE += GuiQuitCb;
+
+        // Load a vertical and horizontal split into the window
+
+        efl.ui.Panes split = new efl.ui.PanesConcrete(win);
+        split.SetSplitRatio(0.75);
+        win.SetContent(split);
+
+        var boxes = SetupUiBoxes(win);
+        efl.ContentConcrete.static_cast(split.Part("first")).SetContent(boxes);
+
+        efl.ui.Panes horiz_split = new efl.ui.PanesConcrete(win);
+        horiz_split.SetDirection(efl.ui.Dir.Horizontal);
+        horiz_split.SetSplitRatio(0.85);
+        
efl.ContentConcrete.static_cast(split.Part("second")).SetContent(horiz_split);
+
+        var table = SetupUiTable(win);
+        
efl.ContentConcrete.static_cast(horiz_split.Part("first")).SetContent(table);
+
+        efl.ui.Button quit_btn = new efl.ui.ButtonConcrete(win);
+        quit_btn.SetText("Quit");
+        sz.W = 150;
+        sz.H = 30;
+        quit_btn.SetHintMax(sz);
+        quit_btn.CLICKED += GuiQuitCb;
+        
efl.ContentConcrete.static_cast(horiz_split.Part("second")).SetContent(quit_btn);
+
+        // Start event loop
+        efl.ui.Config.Run();
+
+        efl.All.Shutdown();
+    }
+}

-- 


Reply via email to