diff -r 000000000000 -r 2483f517c562 ui/wpf/UIcore/Window.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/wpf/UIcore/Window.cs Sun Jan 21 16:30:18 2024 +0100 @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; + +namespace UI +{ + public class MainWindow : Window, Container + { + public Layout Layout + { + get + { + return Container.Layout; + } + set + { + Container.Layout = value; + } + } + + public IntPtr Object; + public Container Container; + + public MainWindow(String title, IntPtr uiobj) + { + Title = title; + Object = uiobj; + Width = 300; + Height = 300; + + Grid windowGrid = new Grid(); + ColumnDefinition column = new ColumnDefinition(); + column.Width = new GridLength(1, GridUnitType.Star); + windowGrid.ColumnDefinitions.Add(column); + this.AddChild(windowGrid); + int rowIndex = 0; + + // menu + Application app = Application.GetInstance(); + System.Windows.Controls.Menu menu = null; + if (!app.Menu.IsEmpty()) + { + menu = app.Menu.CreateMenu(uiobj); + + RowDefinition menuRow = new RowDefinition(); + menuRow.Height = GridLength.Auto; + windowGrid.RowDefinitions.Add(menuRow); + + Grid.SetRow(menu, rowIndex); + Grid.SetColumn(menu, 0); + windowGrid.Children.Add(menu); + rowIndex++; + } + + // toolbar + if(app.ToolBar.HasItems()) + { + System.Windows.Controls.ToolBarTray tray = app.ToolBar.CreateToolBarTray(uiobj); + RowDefinition menuRow = new RowDefinition(); + menuRow.Height = GridLength.Auto; + windowGrid.RowDefinitions.Add(menuRow); + + Grid.SetRow(tray, rowIndex); + Grid.SetColumn(tray, 0); + windowGrid.Children.Add(tray); + rowIndex++; + + if(menu != null) + { + menu.Background = tray.Background; + } + } + + // content + RowDefinition contentRow = new RowDefinition(); + contentRow.Height = new GridLength(1, GridUnitType.Star); + windowGrid.RowDefinitions.Add(contentRow); + BoxContainer vbox = new BoxContainer(BoxOrientation.VERTICAL, 0, 0); + Grid.SetColumn(vbox, 0); + Grid.SetRow(vbox, rowIndex); + windowGrid.Children.Add(vbox); + rowIndex++; + + Container = vbox; + + Closed += CloseEvent; + } + + public void ShowWindow() + { + this.Show(); + Application.GetInstance().AddWindow(this); + } + + public void CloseEvent(object sender, System.EventArgs e) + { + Application.GetInstance().RemoveWindow(this); + } + + public void Add(UIElement control, bool fill) + { + Container.Add(control, fill); + } + } +}