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 { |