ui/wpf/UIcore/Window.cs

changeset 83
a38aec91bd66
parent 82
0cdb8089a29f
child 84
a56c2baa9429
equal deleted inserted replaced
82:0cdb8089a29f 83:a38aec91bd66
7 using System.Windows; 7 using System.Windows;
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, Container
13 { 13 {
14 public IntPtr Object; 14 public IntPtr Object;
15 public Container Container;
15 16
16 public MainWindow(String title, IntPtr uiobj) 17 public MainWindow(String title, IntPtr uiobj)
17 { 18 {
18 Title = title; 19 Title = title;
19 Object = uiobj; 20 Object = uiobj;
20 Width = 300; 21 Width = 300;
21 Height = 300; 22 Height = 300;
22 23
24 Grid windowGrid = new Grid();
25 ColumnDefinition column = new ColumnDefinition();
26 column.Width = new GridLength(1, GridUnitType.Star);
27 windowGrid.ColumnDefinitions.Add(column);
28
29 AddChild(windowGrid);
30 int rowIndex = 0;
31
23 // menu 32 // menu
24 Application app = Application.GetInstance(); 33 Application app = Application.GetInstance();
25 if (!app.AppMenu.IsEmpty()) 34 if (!app.AppMenu.IsEmpty())
26 { 35 {
27 System.Windows.Controls.Menu menu = app.AppMenu.CreateMenu(uiobj); 36 System.Windows.Controls.Menu menu = app.AppMenu.CreateMenu(uiobj);
28 this.AddChild(menu); 37
38 RowDefinition menuRow = new RowDefinition();
39 menuRow.Height = GridLength.Auto;
40 windowGrid.RowDefinitions.Add(menuRow);
41
42 Grid.SetRow(menu, 0);
43 Grid.SetColumn(menu, rowIndex);
44 windowGrid.Children.Add(menu);
45 rowIndex++;
29 } 46 }
30 47
31 GC.KeepAlive(this); // TODO: remove KeepAlive and add the Window to the application 48 // TODO: toolbar
49
50 // content
51 RowDefinition contentRow = new RowDefinition();
52 contentRow.Height = new GridLength(1, GridUnitType.Star);
53 windowGrid.RowDefinitions.Add(contentRow);
54 Grid content = new Grid();
55 Grid.SetColumn(content, 0);
56 Grid.SetRow(content, rowIndex);
57 windowGrid.Children.Add(content);
58 rowIndex++;
59
60 Container = new BoxContainer(content, BoxOrientation.VERTICAL);
61
32 Closed += CloseEvent; 62 Closed += CloseEvent;
33 } 63 }
34 64
35 public static MainWindow CreateMainWindow(String title, IntPtr uiobj) 65 public static MainWindow CreateMainWindow(String title, IntPtr uiobj)
36 { 66 {
45 75
46 public void CloseEvent(object sender, System.EventArgs e) 76 public void CloseEvent(object sender, System.EventArgs e)
47 { 77 {
48 Application.GetInstance().RemoveWindow(this); 78 Application.GetInstance().RemoveWindow(this);
49 } 79 }
80
81 public void Add(UIElement control, bool fill)
82 {
83 Container.Add(control, fill);
84 }
50 } 85 }
51 } 86 }

mercurial