ui/wpf/UIcore/Window.cs

changeset 83
a38aec91bd66
parent 82
0cdb8089a29f
child 84
a56c2baa9429
--- a/ui/wpf/UIcore/Window.cs	Tue Jan 27 09:59:32 2015 +0100
+++ b/ui/wpf/UIcore/Window.cs	Sat Jan 31 11:51:54 2015 +0100
@@ -9,9 +9,10 @@
 
 namespace UI
 {
-    public class MainWindow : Window
+    public class MainWindow : Window, Container
     {
         public IntPtr Object;
+        public Container Container;
         
         public MainWindow(String title, IntPtr uiobj)
         {
@@ -20,15 +21,44 @@
             Width = 300;
             Height = 300;
 
+            Grid windowGrid = new Grid();
+            ColumnDefinition column = new ColumnDefinition();
+            column.Width = new GridLength(1, GridUnitType.Star);
+            windowGrid.ColumnDefinitions.Add(column);
+
+            AddChild(windowGrid);
+            int rowIndex = 0;
+
             // menu
             Application app = Application.GetInstance();
             if (!app.AppMenu.IsEmpty())
             {
                 System.Windows.Controls.Menu menu = app.AppMenu.CreateMenu(uiobj);
-                this.AddChild(menu);
+
+                RowDefinition menuRow = new RowDefinition();
+                menuRow.Height = GridLength.Auto;
+                windowGrid.RowDefinitions.Add(menuRow);
+
+                Grid.SetRow(menu, 0);
+                Grid.SetColumn(menu, rowIndex);
+                windowGrid.Children.Add(menu);
+                rowIndex++;
             }
 
-            GC.KeepAlive(this); // TODO: remove KeepAlive and add the Window to the application
+            // TODO: toolbar
+
+            // content
+            RowDefinition contentRow = new RowDefinition();
+            contentRow.Height = new GridLength(1, GridUnitType.Star);
+            windowGrid.RowDefinitions.Add(contentRow);
+            Grid content = new Grid();
+            Grid.SetColumn(content, 0);
+            Grid.SetRow(content, rowIndex);
+            windowGrid.Children.Add(content);
+            rowIndex++;
+
+            Container = new BoxContainer(content, BoxOrientation.VERTICAL);
+
             Closed += CloseEvent;
         }
 
@@ -47,5 +77,10 @@
         {
             Application.GetInstance().RemoveWindow(this);
         }
+
+        public void Add(UIElement control, bool fill)
+        {
+            Container.Add(control, fill);
+        }
     }
 }

mercurial