2018-02-09 13:06:13 -08:00
|
|
|
using System;
|
|
|
|
|
2019-03-26 04:19:13 -07:00
|
|
|
public class Example : Efl.Csharp.Application
|
2018-02-09 13:06:13 -08:00
|
|
|
{
|
2018-08-22 06:22:29 -07:00
|
|
|
// Callback to quit the application
|
2019-09-06 07:10:16 -07:00
|
|
|
public static void QuitCb(object sender, Efl.Gfx.EntityVisibilityChangedEventArgs e)
|
2018-02-09 13:06:13 -08:00
|
|
|
{
|
2018-08-22 06:22:29 -07:00
|
|
|
// Exit the EFL main loop
|
2020-02-07 00:49:57 -08:00
|
|
|
if (e.Arg == false)
|
2019-03-26 04:19:13 -07:00
|
|
|
Efl.App.AppMain.Quit(0);
|
2018-02-09 13:06:13 -08:00
|
|
|
}
|
|
|
|
|
2019-06-28 15:46:12 -07:00
|
|
|
protected override void OnInitialize(string[] args)
|
2018-02-09 13:06:13 -08:00
|
|
|
{
|
2018-08-22 06:22:29 -07:00
|
|
|
// Create a window and initialize it
|
2019-01-18 07:53:55 -08:00
|
|
|
Efl.Ui.Win win = new Efl.Ui.Win(Efl.App.AppMain);
|
|
|
|
// Set the window's title
|
2020-02-20 08:09:22 -08:00
|
|
|
win.Text = "Hello World";
|
2019-01-18 07:53:55 -08:00
|
|
|
// Request that the window is automatically hidden when the "close"
|
|
|
|
// button is pressed
|
2020-02-20 08:09:22 -08:00
|
|
|
win.Autohide = true;
|
2019-01-18 07:53:55 -08:00
|
|
|
// Hook to the Hide event
|
2019-09-06 07:01:45 -07:00
|
|
|
win.VisibilityChangedEvent += QuitCb;
|
2018-02-09 13:06:13 -08:00
|
|
|
|
2018-08-22 06:22:29 -07:00
|
|
|
// Create a box container
|
2019-01-18 07:53:55 -08:00
|
|
|
var box = new Efl.Ui.Box(win);
|
|
|
|
// Set its minimum size
|
2020-02-20 08:09:22 -08:00
|
|
|
box.HintSizeMin = new Eina.Size2D(360, 240);
|
2019-01-18 07:53:55 -08:00
|
|
|
// Set the box as the content for the window
|
|
|
|
// The window size will adapt to the box size
|
|
|
|
win.SetContent(box);
|
2018-02-09 13:06:13 -08:00
|
|
|
|
2018-08-22 06:22:29 -07:00
|
|
|
// Create a text label widget
|
2019-12-11 06:51:03 -08:00
|
|
|
var label = new Efl.Ui.Textbox(box);
|
2019-01-18 07:53:55 -08:00
|
|
|
// Set its content and customize it
|
2020-02-20 08:09:22 -08:00
|
|
|
label.Text = "Hello World. This is an Efl.Ui application!";
|
2019-07-17 03:49:42 -07:00
|
|
|
label.Editable = false;
|
|
|
|
label.SelectionAllowed = false;
|
2020-02-20 08:09:22 -08:00
|
|
|
label.HintWeight = (1.0, 0.9);
|
|
|
|
label.HintFill = (false, false);
|
|
|
|
label.HintAlign = ((Efl.Gfx.Align)0.5, (Efl.Gfx.Align)0.5);
|
2019-01-18 07:53:55 -08:00
|
|
|
// Add the text to the box container
|
2019-04-23 03:32:06 -07:00
|
|
|
box.Pack(label);
|
2018-02-09 13:06:13 -08:00
|
|
|
|
2018-08-22 06:22:29 -07:00
|
|
|
// Create a button widget
|
2019-01-18 07:53:55 -08:00
|
|
|
var button = new Efl.Ui.Button(box);
|
|
|
|
// Customize it
|
2020-02-20 08:09:22 -08:00
|
|
|
button.Text = "Quit";
|
|
|
|
button.HintWeight = (1.0, 0.1);
|
2019-01-18 07:53:55 -08:00
|
|
|
// Set the method to be called when the button is pressed
|
2019-09-06 07:10:16 -07:00
|
|
|
button.ClickedEvent += (object sender, Efl.Input.ClickableClickedEventArgs e) => { Efl.App.AppMain.Quit(0); };
|
2019-01-18 07:53:55 -08:00
|
|
|
// Add the button to the box container
|
2019-04-23 03:32:06 -07:00
|
|
|
box.Pack(button);
|
2019-03-26 04:19:13 -07:00
|
|
|
}
|
2018-02-09 13:06:13 -08:00
|
|
|
|
2019-03-26 04:19:13 -07:00
|
|
|
#if WIN32
|
|
|
|
[STAThreadAttribute()]
|
|
|
|
#endif
|
|
|
|
public static void Main()
|
|
|
|
{
|
|
|
|
var example = new Example();
|
|
|
|
example.Launch();
|
2018-02-09 13:06:13 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|