70 lines
2.1 KiB
C#
70 lines
2.1 KiB
C#
using System;
|
|
|
|
public class Example
|
|
{
|
|
// Callback to quit the application
|
|
public static void QuitCb(object sender, EventArgs e)
|
|
{
|
|
// Exit the EFL main loop
|
|
efl.ui.Config.Exit();
|
|
}
|
|
|
|
#if WIN32
|
|
[STAThreadAttribute()]
|
|
#endif
|
|
public static void Main()
|
|
{
|
|
// Initialize EFL and all UI components
|
|
efl.All.Init(efl.Components.Ui);
|
|
|
|
// Create a window and initialize it
|
|
efl.ui.IWin win = new efl.ui.Win(efl.App.GetLoopMain(), (efl.ui.IWin ewin) => {
|
|
// Set the window's title
|
|
ewin.SetText("Hello World");
|
|
// Request that the window is automatically hidden when the "close"
|
|
// button is pressed
|
|
ewin.SetAutohide(true);
|
|
// Hook to the Hide event
|
|
ewin.HideEvt += QuitCb;
|
|
});
|
|
|
|
// Create a box container
|
|
efl.ui.IBox box = new efl.ui.Box(win, (efl.ui.IBox ebox) => {
|
|
// Set its minimum size
|
|
ebox.SetHintMin(new eina.Size2D(360, 240));
|
|
// Set the box as the content for the window
|
|
// The window size will adapt to the box size
|
|
win.SetContent(ebox);
|
|
});
|
|
|
|
// Create a text label widget
|
|
new efl.ui.Text(box, (efl.ui.IText etext) => {
|
|
// Set its content and customize it
|
|
etext.SetText("Hello World. This is an Efl.Ui application!");
|
|
etext.SetSelectionAllowed(false);
|
|
etext.SetHintWeight(1.0, 0.9);
|
|
etext.SetHintAlign(0.5, 0.5);
|
|
// Add the text to the box container
|
|
box.DoPack(etext);
|
|
});
|
|
|
|
// Create a button widget
|
|
new efl.ui.Button(box, (efl.ui.IButton ebutton) => {
|
|
// Customize it
|
|
ebutton.SetText("Quit");
|
|
ebutton.SetHintWeight(1.0, 0.1);
|
|
// Set the method to be called when the button is pressed
|
|
ebutton.ClickedEvt += QuitCb;
|
|
// Add the button to the box container
|
|
box.DoPack(ebutton);
|
|
});
|
|
|
|
// Start the EFL main loop
|
|
efl.ui.Config.Run();
|
|
|
|
// Shutdown EFL
|
|
efl.All.Shutdown();
|
|
}
|
|
}
|
|
|