summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-09-13 11:37:27 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-09-13 11:37:27 -0300
commit535b1e0dbe5a8d5956cab445194f44ba437974bf (patch)
treec397c1a8d6eb2d8412583de8f364a70b9dabcf2b
parent3aecb39a18ba6d6c76a6fdb0cb2ddebd688b38d4 (diff)
csharp: Add tentative MVVM exampledevs/lauromoura/cv
-rw-r--r--reference/csharp/ui/src/meson.build7
-rw-r--r--reference/csharp/ui/src/ui_mvvm_basic.cs83
2 files changed, 90 insertions, 0 deletions
diff --git a/reference/csharp/ui/src/meson.build b/reference/csharp/ui/src/meson.build
index bfe5e9a9..cf376ec9 100644
--- a/reference/csharp/ui/src/meson.build
+++ b/reference/csharp/ui/src/meson.build
@@ -27,3 +27,10 @@ executable('efl_reference_ui_custom_widget',
27 cs_args : efl_mono_libs, 27 cs_args : efl_mono_libs,
28 install : true 28 install : true
29) 29)
30
31executable('efl_reference_ui_mvvm_basic',
32 files(['ui_mvvm_basic.cs']),
33 dependencies : deps,
34 cs_args : efl_mono_libs,
35 install : true
36)
diff --git a/reference/csharp/ui/src/ui_mvvm_basic.cs b/reference/csharp/ui/src/ui_mvvm_basic.cs
new file mode 100644
index 00000000..4d22d94a
--- /dev/null
+++ b/reference/csharp/ui/src/ui_mvvm_basic.cs
@@ -0,0 +1,83 @@
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
38 var factory = new Efl.Ui.ItemFactory<Efl.Ui.ListDefaultItem>(win);
39 /* factory.TextPart().Markup().Bind("Nick"); */
40 factory.PropertyBind("text", "Nick");
41
42 var model = WeatherStation.CreateModel(Efl.App.AppMain);
43 model.SetProperty("item.width", 1);
44 model.SetProperty("item.height", 1);
45
46 Console.WriteLine($"Width: {model.GetProperty("item.width")}");
47
48 /* var list = new Efl.Ui.ListView(box); */
49
50 /* list.LayoutFactory = factory; */
51 /* list.Model = model; */
52
53 var manager = new Efl.Ui.PositionManager.List(win);
54 var list = new Efl.Ui.CollectionView(win);
55
56 Eina.Log.Error("Setting manager");
57 list.PositionManager = manager;
58 Eina.Log.Error("Setting model");
59 list.Model = model;
60 Eina.Log.Error("Setting factory");
61 list.Factory = factory;
62
63 /* var box = new Efl.Ui.Box(win); */
64 /* box.PackEnd(list); */
65 win.SetContent(list);
66 win.SetSize(new Eina.Size2D(640, 480));
67 win.Visible = true;
68 }
69
70 void QuitEvt(object sender, Efl.Gfx.EntityVisibilityChangedEventArgs ev)
71 {
72 if (ev.arg == false)
73 {
74 Efl.App.AppMain.Quit(0);
75 }
76 }
77
78 public static void Main()
79 {
80 var app = new Application();
81 app.Launch();
82 }
83}