ui/wpf/UIcore/Window.cs

changeset 81
5eb765a7a793
parent 78
135920fe441b
child 82
0cdb8089a29f
equal deleted inserted replaced
80:40be5c189e2e 81:5eb765a7a793
8 using System.Windows.Controls; 8 using System.Windows.Controls;
9 9
10 namespace UI 10 namespace UI
11 { 11 {
12 public class MainWindow : Window 12 public class MainWindow : Window
13 { 13 {
14 private Label label1;
15
16 public MainWindow(String title) 14 public MainWindow(String title)
17 { 15 {
18 Title = title; 16 Title = title;
19 Width = 300; 17 Width = 300;
20 Height = 300; 18 Height = 300;
21 GC.KeepAlive(this); // remove KeepAlive and add the Window to the application 19
20 // menu
21 Application app = Application.GetInstance();
22 if (!app.AppMenu.IsEmpty())
23 {
24 System.Windows.Controls.Menu menu = app.AppMenu.CreateMenu();
25 this.AddChild(menu);
26 }
27
28 GC.KeepAlive(this); // TODO: remove KeepAlive and add the Window to the application
29 Closed += CloseEvent;
22 } 30 }
23 31
24 public static MainWindow CreateMainWindow(String title) 32 public static MainWindow CreateMainWindow(String title)
25 { 33 {
26 return Application.GetInstance().Exec<MainWindow>(() => new MainWindow(title)); 34 return Application.GetInstance().Exec<MainWindow>(() => new MainWindow(title));
27 } 35 }
28 36
29 public void ShowWindow() 37 public void ShowWindow()
30 { 38 {
31 Application.GetInstance().Exec(() => this.Show()); 39 Application.GetInstance().Exec(() => this.Show());
40 Application.GetInstance().AddWindow(this);
41 }
42
43 public void CloseEvent(object sender, System.EventArgs e)
44 {
45 Application.GetInstance().RemoveWindow(this);
32 } 46 }
33 } 47 }
34 } 48 }

mercurial