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-03-22 01:13:15 -07:00
|
|
|
public static void QuitCb(object sender, Efl.Gfx.IEntityVisibilityChangedEvt_Args e)
|
2018-02-09 13:06:13 -08:00
|
|
|
{
|
2018-08-22 06:22:29 -07:00
|
|
|
// Exit the EFL main loop
|
2019-03-04 09:17:36 -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-03-26 04:19:13 -07:00
|
|
|
protected override void OnInitialize(Eina.Array<System.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
|
|
|
|
win.SetText("Hello World");
|
|
|
|
// Request that the window is automatically hidden when the "close"
|
|
|
|
// button is pressed
|
|
|
|
win.SetAutohide(true);
|
|
|
|
// Hook to the Hide event
|
2019-03-04 09:17:36 -08:00
|
|
|
win.VisibilityChangedEvt += 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
|
2019-03-05 00:30:09 -08:00
|
|
|
box.SetHintSizeMin(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-01-18 07:53:55 -08:00
|
|
|
var label = new Efl.Ui.Text(box);
|
|
|
|
// Set its content and customize it
|
|
|
|
label.SetText("Hello World. This is an Efl.Ui application!");
|
|
|
|
label.SetSelectionAllowed(false);
|
|
|
|
label.SetHintWeight(1.0, 0.9);
|
|
|
|
label.SetHintAlign(0.5, 0.5);
|
|
|
|
// 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
|
|
|
|
button.SetText("Quit");
|
|
|
|
button.SetHintWeight(1.0, 0.1);
|
|
|
|
// Set the method to be called when the button is pressed
|
2019-03-26 04:19:13 -07:00
|
|
|
button.ClickedEvt += (object sender, EventArgs 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|