Created
February 13, 2017 06:28
-
-
Save SlowLogicBoy/afcd5e068cb8acc28fd2e5b9dd367479 to your computer and use it in GitHub Desktop.
Reloading Eto.Forms content while debugging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Eto.Forms; | |
using Eto.Drawing; | |
namespace EtoApp1 | |
{ | |
public class MainForm : Form | |
{ | |
public MainForm () | |
{ | |
Title = "My Eto Form"; | |
ClientSize = new Size (400, 350); | |
#if DEBUG | |
KeyUp += (sender, args) => | |
{ | |
if (args.Key == Keys.F5) | |
{ | |
LoadContent (); | |
} | |
}; | |
#endif | |
LoadContent(); | |
} | |
private void LoadContent () | |
{ | |
Content = new StackLayout | |
{ | |
Padding = 10, | |
Items = | |
{ | |
"Hello World!", | |
// add more controls here | |
} | |
}; | |
// create a few commands that can be used for the menu and toolbar | |
var clickMe = new Command {MenuText = "Click Me!", ToolBarText = "Click Me!"}; | |
clickMe.Executed += (sender, e) => MessageBox.Show (this, "I was clicked!"); | |
var quitCommand = new Command {MenuText = "Quit", Shortcut = Application.Instance.CommonModifier | Keys.Q}; | |
quitCommand.Executed += (sender, e) => Application.Instance.Quit (); | |
var aboutCommand = new Command {MenuText = "About..."}; | |
aboutCommand.Executed += (sender, e) => MessageBox.Show (this, "About my app..."); | |
// create menu | |
Menu = new MenuBar | |
{ | |
Items = | |
{ | |
// File submenu | |
new ButtonMenuItem {Text = "&File", Items = {clickMe}}, | |
// new ButtonMenuItem { Text = "&Edit", Items = { /* commands/items */ } }, | |
// new ButtonMenuItem { Text = "&View", Items = { /* commands/items */ } }, | |
}, | |
ApplicationItems = | |
{ | |
// application (OS X) or file menu (others) | |
new ButtonMenuItem {Text = "&Preferences..."}, | |
}, | |
QuitItem = quitCommand, | |
AboutItem = aboutCommand | |
}; | |
// create toolbar | |
ToolBar = new ToolBar {Items = {clickMe}}; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment