From b8f57276efdfdfb60597cf4971e58bbf5883864d Mon Sep 17 00:00:00 2001 From: Lauro Moura Date: Thu, 17 Oct 2019 13:09:27 -0300 Subject: [PATCH] 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(+) create mode 100644 apps/csharp/mvvm-example/meson.build create mode 100644 apps/csharp/mvvm-example/src/meson.build create mode 100644 apps/csharp/mvvm-example/src/mvvm_basic.cs 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 CreateModel(Efl.Loop loop) + { + Efl.UserModel stations = new Efl.UserModel(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(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(); + } +}