aboutsummaryrefslogtreecommitdiffstats
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
parentcsharp: Use basic components in core event test (diff)
downloadexamples-devs/lauromoura/cv.tar.gz
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',
cs_args : efl_mono_libs,
install : true
)
+
+executable('efl_reference_ui_mvvm_basic',
+ files(['ui_mvvm_basic.cs']),
+ dependencies : deps,
+ cs_args : efl_mono_libs,
+ install : true
+)
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 @@
+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);
+ /* factory.TextPart().Markup().Bind("Nick"); */
+ factory.PropertyBind("text", "Nick");
+
+ var model = WeatherStation.CreateModel(Efl.App.AppMain);
+ model.SetProperty("item.width", 1);
+ model.SetProperty("item.height", 1);
+
+ Console.WriteLine($"Width: {model.GetProperty("item.width")}");
+
+ /* var list = new Efl.Ui.ListView(box); */
+
+ /* list.LayoutFactory = factory; */
+ /* list.Model = model; */
+
+ var manager = new Efl.Ui.PositionManager.List(win);
+ var list = new Efl.Ui.CollectionView(win);
+
+ Eina.Log.Error("Setting manager");
+ list.PositionManager = manager;
+ Eina.Log.Error("Setting model");
+ list.Model = model;
+ Eina.Log.Error("Setting factory");
+ list.Factory = factory;
+
+ /* var box = new Efl.Ui.Box(win); */
+ /* box.PackEnd(list); */
+ 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();
+ }
+}