From 3053ccd67229cf90e8ab8c825cc60b295c425e74 Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Wed, 19 Dec 2018 17:51:26 +0100 Subject: [PATCH] demonstrate application and SimpleApplication --- apps/csharp/life/src/life_main.cs | 29 +++++++++++++------ apps/csharp/texteditor/src/texteditor_main.cs | 25 +++++----------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/apps/csharp/life/src/life_main.cs b/apps/csharp/life/src/life_main.cs index 3de8d68a..a004b0f8 100644 --- a/apps/csharp/life/src/life_main.cs +++ b/apps/csharp/life/src/life_main.cs @@ -1,9 +1,13 @@ using System; -public class LifeWindow +public class LifeWindow : Efl.Csharp.Application { private LifeBoard lifeBoard; private LifeRender lifeRender; + private Efl.Ui.Win win; + public LifeWindow() { + + } void ResizeEvt(object sender, EventArgs ev) { @@ -31,12 +35,11 @@ public class LifeWindow void KeyDownEvt(object sender, Efl.Input.IInterfaceKeyDownEvt_Args ev) { - Efl.Ui.Win win = (Efl.Ui.Win)sender; if (ev.arg.GetKey() == "space") lifeBoard.TogglePause(win); } - public LifeWindow() + protected override void OnInitialize(Eina.Array args) { Efl.Ui.Win win = new Efl.Ui.Win(parent: null, winName: "Life", winType: Efl.Ui.WinType.Basic); win.SetText("EFL Life"); @@ -61,19 +64,27 @@ public class LifeWindow lifeBoard.Run(win); } + protected void OnPause() { + if (win != null) { + lifeBoard.TogglePause(win); + } + } + protected void OnResume() { + if (win != null) { + lifeBoard.TogglePause(win); + } + } + protected void OnTerminate() { + Console.WriteLine("Goodbye."); + } } public class Example { public static void Main() { - Efl.All.Init(Efl.Components.Ui); - var lifeWin = new LifeWindow(); - // start the mainloop - Efl.Ui.Config.Run(); - - Efl.All.Shutdown(); + lifeWin.Launch(); } } diff --git a/apps/csharp/texteditor/src/texteditor_main.cs b/apps/csharp/texteditor/src/texteditor_main.cs index e0591f13..f4a2347d 100644 --- a/apps/csharp/texteditor/src/texteditor_main.cs +++ b/apps/csharp/texteditor/src/texteditor_main.cs @@ -17,7 +17,7 @@ using System; -public class TextEditor +public class TextEditor : Efl.Csharp.Application { private Efl.Ui.Win win; // The main window private Efl.Ui.Text editorTextBox; // The main text entry @@ -31,6 +31,10 @@ public class TextEditor private readonly string filename = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "texteditor_example.txt"); + public TextEditor() { + + } + // Quits the application private void GUIQuitCb(object sender, Efl.Gfx.IEntityVisibilityChangedEvt_Args ea) { @@ -151,7 +155,7 @@ public class TextEditor } // Builds the user interface for the text editor - public TextEditor() + protected override void OnInitialize(Eina.Array args) { // Create a window and initialize it win = new Efl.Ui.Win(parent: Efl.App.AppMain); @@ -180,13 +184,6 @@ public class TextEditor // Initial refresh of the toolbar buttons GUIToolbarRefresh(); } - - // This method won't return until the application quits - public void Run() - { - // Start the EFL main loop - Efl.Ui.Config.Run(); - } } public class Example @@ -196,14 +193,8 @@ public class Example #endif public static void Main() { - // Initialize EFL and all UI components - Efl.All.Init(Efl.Components.Ui); - - var textEditor = new TextEditor(); - textEditor.Run(); - - // Shutdown EFL - Efl.All.Shutdown(); + TextEditor editor = new TextEditor(); + editor.Launch(); } }