diff options
Diffstat (limited to 'Samples/HelloWorld')
| -rw-r--r-- | Samples/HelloWorld/main.cs | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/Samples/HelloWorld/main.cs b/Samples/HelloWorld/main.cs index a9d48fc9..14a1a2ad 100644 --- a/Samples/HelloWorld/main.cs +++ b/Samples/HelloWorld/main.cs @@ -1,13 +1,42 @@ -using Crow; +using System; +using Crow; namespace HelloWorld { class Program : Interface { + Command CMDQuit; static void Main (string[] args) { using (Program vke = new Program ()) { - vke.Load ("#HelloWorld.helloworld.crow"); vke.Run (); } } + protected override void Startup () + { + CMDQuit = new Command (new Action (() => running = false)) { Caption = "Quit", Icon = new SvgPicture ("#Crow.Icons.exit-symbol.svg") }; + + Widget w = Load ("#HelloWorld.helloworld.crow"); + w.KeyPress += W_KeyPress; + w.DataSource = this; + } + + Color [] colors = { Color.Blue, Color.DarkGoldenRod, Color.Red, Color.Azure, Color.Brown, Color.Black, Color.White, Color.Pink }; + int ptr = 0; + + void W_KeyPress (object sender, KeyPressEventArgs e) + { + switch (e.KeyChar) { + case 'w': + LoadIMLFragment ($"<DockWindow Name='win{ptr}' Left='450' Top='450' Width='150' Height='150' Background='{colors [ptr]}'/>"); + break; + case 'x': + LoadIMLFragment ($"<Window Name='win{ptr}' Left='450' Top='450' Width='150' Height='150' Background='{colors [ptr]}'/>"); + break; + } + + ptr++; + if (ptr == colors.Length) + ptr = 0; + } + } } |