public void AppendContent(ContentPane contentPane) { List <Pane> dockedPanes = contentPane.DockedPanes; foreach (Pane pane in dockedPanes.ToArray()) { contentPane.RemovePane(pane); MainContent.AddPane(pane); } }
public void Docking(DockPane dockPane, EDock dockPos) { GridSplitter splitter = new GridSplitter(); splitter.Background = Brushes.LightGray; dockPane.ParentWindow = null; dockPane.ParentDockPane = this; dockPane.DockedPos = dockPos; switch (dockPos) { case EDock.Top: { if (panelTop.Children.Count > 0) { if (panelTop.Children[0] is DockPane dockedPane) { dockedPane.Docking(dockPane, EDock.Center); } } else { splitter.Height = 10; splitter.HorizontalAlignment = HorizontalAlignment.Stretch; splitter.SetValue(Grid.ColumnProperty, 0); splitter.SetValue(Grid.ColumnSpanProperty, 5); splitter.SetValue(Grid.RowProperty, 1); panelTop.Children.Add(dockPane); } } break; case EDock.Left: { if (panelLeft.Children.Count > 0) { if (panelLeft.Children[0] is DockPane dockedPane) { dockedPane.Docking(dockPane, EDock.Center); } } else { splitter.Width = 10; splitter.HorizontalAlignment = HorizontalAlignment.Stretch; splitter.SetValue(Grid.ColumnProperty, 1); splitter.SetValue(Grid.RowProperty, 2); panelLeft.Children.Add(dockPane); } } break; case EDock.Center: { if (panelCenter.Children.Count > 0) { if (panelCenter.Children[0] is ContentPane contentPane) { ContentPane dockedContentPane = dockPane.panelCenter.Children[0] as ContentPane; foreach (Pane pane in dockedContentPane.DockedPanes.ToArray()) { dockedContentPane.RemovePane(pane); contentPane.AddPane(pane); } } } else { panelCenter.Children.Add(dockPane); } } break; case EDock.Right: { if (panelRight.Children.Count > 0) { if (panelRight.Children[0] is DockPane dockedPane) { dockedPane.Docking(dockPane, EDock.Center); } } else { splitter.Width = 10; splitter.HorizontalAlignment = HorizontalAlignment.Stretch; splitter.SetValue(Grid.ColumnProperty, 3); splitter.SetValue(Grid.RowProperty, 2); panelRight.Children.Add(dockPane); } } break; case EDock.Bottom: { if (panelBottom.Children.Count > 0) { if (panelBottom.Children[0] is DockPane dockedPane) { dockedPane.Docking(dockPane, EDock.Center); } } else { splitter.Height = 10; splitter.HorizontalAlignment = HorizontalAlignment.Stretch; splitter.SetValue(Grid.ColumnProperty, 0); splitter.SetValue(Grid.ColumnSpanProperty, 5); splitter.SetValue(Grid.RowProperty, 3); panelBottom.Children.Add(dockPane); } } break; default: break; } DockManager.Instance.Sample = this; mainGrid.Children.Add(splitter); }