summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-10-17 13:09:27 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-10-17 13:09:27 -0300
commitb8f57276efdfdfb60597cf4971e58bbf5883864d (patch)
treefcc1e91032ae19746909b6dcabf45c9829309a26
parentb8fd0c3b74d5a7c9db92c187daddfdf2a3add4c9 (diff)
Initial version of demo MVVM appHEADmaster
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
-rw-r--r--apps/csharp/mvvm-example/meson.build10
-rw-r--r--apps/csharp/mvvm-example/src/meson.build12
-rw-r--r--apps/csharp/mvvm-example/src/mvvm_basic.cs69
3 files changed, 91 insertions, 0 deletions
diff --git a/apps/csharp/mvvm-example/meson.build b/apps/csharp/mvvm-example/meson.build
new file mode 100644
index 0000000..a6acc56
--- /dev/null
+++ b/apps/csharp/mvvm-example/meson.build
@@ -0,0 +1,10 @@
1project(
2 'efl-example-mvvm', 'cs',
3 version : '0.0.1',
4 meson_version : '>= 0.49.0')
5
6efl_mono = dependency('efl-mono', version : '>=1.23.99')
7efl_mono_libs = efl_mono.get_pkgconfig_variable('mono_libs')
8
9subdir('src')
10
diff --git a/apps/csharp/mvvm-example/src/meson.build b/apps/csharp/mvvm-example/src/meson.build
new file mode 100644
index 0000000..d8905d1
--- /dev/null
+++ b/apps/csharp/mvvm-example/src/meson.build
@@ -0,0 +1,12 @@
1src = files([
2 'mvvm_basic.cs',
3])
4
5deps = [efl_mono]
6
7executable('efl_example_mvvm', src,
8 dependencies : deps,
9 cs_args : efl_mono_libs,
10 install : true
11)
12
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 0000000..cd3fdd5
--- /dev/null
+++ b/apps/csharp/mvvm-example/src/mvvm_basic.cs
@@ -0,0 +1,69 @@
1using System;
2
3class WeatherStation
4{
5 public String Nick { get; set; }
6 public float Temperature { get; set; }
7
8 public static Efl.UserModel<WeatherStation> CreateModel(Efl.Loop loop)
9 {
10 Efl.UserModel<WeatherStation> stations = new Efl.UserModel<WeatherStation>(loop);
11 stations.Add (new WeatherStation{ Nick="FLN", Temperature=20 });
12 stations.Add (new WeatherStation{ Nick="SAO", Temperature=25 });
13 stations.Add (new WeatherStation{ Nick="RIO", Temperature=35 });
14 stations.Add (new WeatherStation{ Nick="BSB", Temperature=30 });
15
16 return stations;
17 }
18}
19
20class WeatherServer
21{
22}
23
24class Application : Efl.Csharp.Application
25{
26 private Efl.Ui.Win win;
27
28 protected override void OnInitialize(string[] args)
29 {
30 win = new Efl.Ui.Win(parent: null, winName: "MVVM Example",
31 winType: Efl.Ui.WinType.Basic);
32 win.SetText("EFL Life");
33 win.SetAutohide(true);
34
35 win.VisibilityChangedEvent += QuitEvt;
36
37 var factory = new Efl.Ui.ItemFactory<Efl.Ui.ListDefaultItem>(win);
38 // Text property is temporarily excluded from the extension method generation
39 // due to conflicts with the text classes.
40 factory.BindProperty("text", "Nick");
41
42 var model = WeatherStation.CreateModel(Efl.App.AppMain);
43
44 var manager = new Efl.Ui.PositionManager.List(win);
45 var list = new Efl.Ui.CollectionView(win);
46
47 list.PositionManager = manager;
48 list.Model = model;
49 list.Factory = factory;
50
51 win.SetContent(list);
52 win.SetSize(new Eina.Size2D(640, 480));
53 win.Visible = true;
54 }
55
56 void QuitEvt(object sender, Efl.Gfx.EntityVisibilityChangedEventArgs ev)
57 {
58 if (ev.arg == false)
59 {
60 Efl.App.AppMain.Quit(0);
61 }
62 }
63
64 public static void Main()
65 {
66 var app = new Application();
67 app.Launch();
68 }
69}