lauromoura pushed a commit to branch master.

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

commit b8f57276efdfdfb60597cf4971e58bbf5883864d
Author: Lauro Moura <[email protected]>
Date:   Thu Oct 17 13:09:27 2019 -0300

    Initial version of demo MVVM app
    
    Summary:
    For now, a static model with a simple CollectionView.
    
    The idea is to create a model that fetches some info from the web,
    like weather forecast, and show it to the user.
    
    Depends on D10300
    
    Reviewers: SanghyeonLee, felipealmeida, cedric, bu5hm4n
    
    Reviewed By: SanghyeonLee
    
    Subscribers: brunobelo
    
    Differential Revision: https://phab.enlightenment.org/D10302
---
 apps/csharp/mvvm-example/meson.build       | 10 +++++
 apps/csharp/mvvm-example/src/meson.build   | 12 ++++++
 apps/csharp/mvvm-example/src/mvvm_basic.cs | 69 ++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+)

diff --git a/apps/csharp/mvvm-example/meson.build 
b/apps/csharp/mvvm-example/meson.build
new file mode 100644
index 00000000..a6acc56f
--- /dev/null
+++ b/apps/csharp/mvvm-example/meson.build
@@ -0,0 +1,10 @@
+project(
+  'efl-example-mvvm', 'cs',
+  version : '0.0.1',
+  meson_version : '>= 0.49.0')
+
+efl_mono = dependency('efl-mono', version : '>=1.23.99')
+efl_mono_libs = efl_mono.get_pkgconfig_variable('mono_libs')
+
+subdir('src')
+
diff --git a/apps/csharp/mvvm-example/src/meson.build 
b/apps/csharp/mvvm-example/src/meson.build
new file mode 100644
index 00000000..d8905d1c
--- /dev/null
+++ b/apps/csharp/mvvm-example/src/meson.build
@@ -0,0 +1,12 @@
+src = files([
+  'mvvm_basic.cs',
+])
+
+deps = [efl_mono]
+
+executable('efl_example_mvvm', src,
+  dependencies : deps,
+  cs_args : efl_mono_libs,
+  install : true
+)
+
diff --git a/apps/csharp/mvvm-example/src/mvvm_basic.cs 
b/apps/csharp/mvvm-example/src/mvvm_basic.cs
new file mode 100644
index 00000000..cd3fdd50
--- /dev/null
+++ b/apps/csharp/mvvm-example/src/mvvm_basic.cs
@@ -0,0 +1,69 @@
+using System;
+
+class WeatherStation
+{
+    public String Nick { get; set; }
+    public float Temperature { get; set; }
+
+    public static Efl.UserModel<WeatherStation> CreateModel(Efl.Loop loop)
+    {
+        Efl.UserModel<WeatherStation> stations = new 
Efl.UserModel<WeatherStation>(loop);
+        stations.Add (new WeatherStation{ Nick="FLN", Temperature=20 });
+        stations.Add (new WeatherStation{ Nick="SAO", Temperature=25 });
+        stations.Add (new WeatherStation{ Nick="RIO", Temperature=35 });
+        stations.Add (new WeatherStation{ Nick="BSB", Temperature=30 });
+
+        return stations;
+    }
+}
+
+class WeatherServer
+{
+}
+
+class Application : Efl.Csharp.Application
+{
+    private Efl.Ui.Win win;
+
+    protected override void OnInitialize(string[] args)
+    {
+        win = new Efl.Ui.Win(parent: null, winName: "MVVM Example",
+                             winType: Efl.Ui.WinType.Basic);
+        win.SetText("EFL Life");
+        win.SetAutohide(true);
+
+        win.VisibilityChangedEvent += QuitEvt;
+
+        var factory = new Efl.Ui.ItemFactory<Efl.Ui.ListDefaultItem>(win);
+        // Text property is temporarily excluded from the extension method 
generation
+        // due to conflicts with the text classes.
+        factory.BindProperty("text", "Nick");
+
+        var model = WeatherStation.CreateModel(Efl.App.AppMain);
+
+        var manager = new Efl.Ui.PositionManager.List(win);
+        var list = new Efl.Ui.CollectionView(win);
+
+        list.PositionManager = manager;
+        list.Model = model;
+        list.Factory = factory;
+
+        win.SetContent(list);
+        win.SetSize(new Eina.Size2D(640, 480));
+        win.Visible = true;
+    }
+
+    void QuitEvt(object sender, Efl.Gfx.EntityVisibilityChangedEventArgs ev)
+    {
+        if (ev.arg == false)
+        {
+            Efl.App.AppMain.Quit(0);
+        }
+    }
+
+    public static void Main()
+    {
+        var app = new Application();
+        app.Launch();
+    }
+}

-- 


Reply via email to