private void InsertDockPane(Grid parentSplitterPane, SelectablePane selectablePane, DockPane dockPaneToInsert, bool isHorizontalSplit) { parentSplitterPane.Children.Remove(selectablePane); SplitterPane newGrid = ILayoutFactory.MakeSplitterPane(isHorizontalSplit); parentSplitterPane.Children.Add(newGrid); Grid.SetRow(newGrid, Grid.GetRow(selectablePane)); Grid.SetColumn(newGrid, Grid.GetColumn(selectablePane)); newGrid.AddChild(selectablePane, true); newGrid.AddChild(dockPaneToInsert, false); }
public SelectablePane FindElementOfType(Type type, Grid grid) { System.Diagnostics.Trace.Assert(grid != null); if (grid.GetType() == type) { return(grid as SelectablePane); } foreach (var child in grid.Children) { if (child is Grid) { SelectablePane selectablePane = FindElementOfType(type, child as Grid); if (selectablePane != null) { return(selectablePane); } } } return(null); }
void IFloatingPaneHost.Unfloat(FloatingPane floatingPane, SelectablePane selectedPane, WindowLocation windowLocation) { IDockPaneManager.Unfloat(floatingPane, selectedPane, windowLocation); }
public void Unfloat(FloatingPane floatingPane, SelectablePane selectedPane, WindowLocation windowLocation) { Application.Current.Dispatcher.Invoke((Action) delegate { if ( (floatingPane == null) || ((selectedPane != null) && !(selectedPane.Parent is SplitterPane) && !(selectedPane.Parent is DocumentPanel) && (selectedPane.Parent != IDockPaneHost)) ) { return; } SplitterPane parentSplitterPane = null; DockPane dockPane = null; switch (windowLocation) { case WindowLocation.BottomSide: case WindowLocation.TopSide: case WindowLocation.LeftSide: case WindowLocation.RightSide: if (floatingPane is FloatingToolPaneGroup) { dockPane = ILayoutFactory.MakeToolPaneGroup(); } else { dockPane = ILayoutFactory.MakeDocumentPaneGroup(); } dockPane.IViewContainer.ExtractDocuments(floatingPane.IViewContainer); floatingPane.Close(); parentSplitterPane = ILayoutFactory.MakeSplitterPane((windowLocation == WindowLocation.TopSide) || (windowLocation == WindowLocation.BottomSide)); bool isFirst = (windowLocation == WindowLocation.TopSide) || (windowLocation == WindowLocation.LeftSide); parentSplitterPane.AddChild(dockPane, isFirst); if (IDockPaneHost.Children.Count == 0) { IDockPaneHost.Children.Add(parentSplitterPane); } else { Grid rootPane = IDockPaneHost.RootPane; IDockPaneHost.RootPane = parentSplitterPane; parentSplitterPane.AddChild(rootPane, !isFirst); } break; case WindowLocation.Right: case WindowLocation.Left: case WindowLocation.Top: case WindowLocation.Bottom: if (floatingPane is FloatingToolPaneGroup) { dockPane = ILayoutFactory.MakeToolPaneGroup(); } else { dockPane = ILayoutFactory.MakeDocumentPaneGroup(); } dockPane.IViewContainer.ExtractDocuments(floatingPane.IViewContainer); floatingPane.Close(); SplitterPane newGrid = ILayoutFactory.MakeSplitterPane((windowLocation == WindowLocation.Top) || (windowLocation == WindowLocation.Bottom)); if (selectedPane.Parent is DocumentPanel) { DocumentPanel documentPanel = selectedPane.Parent as DocumentPanel; documentPanel.Children.Remove(selectedPane); documentPanel.Children.Add(newGrid); } else { parentSplitterPane = (selectedPane.Parent as SplitterPane); parentSplitterPane.Children.Remove(selectedPane); parentSplitterPane.Children.Add(newGrid); Grid.SetRow(newGrid, Grid.GetRow(selectedPane)); Grid.SetColumn(newGrid, Grid.GetColumn(selectedPane)); } bool isTargetFirst = (windowLocation == WindowLocation.Right) || (windowLocation == WindowLocation.Bottom); newGrid.AddChild(selectedPane, isTargetFirst); newGrid.AddChild(dockPane, !isTargetFirst); break; case WindowLocation.Middle: if (selectedPane is DockPane) { (selectedPane as DockPane).IViewContainer.ExtractDocuments(floatingPane.IViewContainer); floatingPane.Close(); } else if (selectedPane is DocumentPanel) { DocumentPaneGroup documentPaneGroup = ILayoutFactory.MakeDocumentPaneGroup(); selectedPane.Children.Add(documentPaneGroup); documentPaneGroup.IViewContainer.ExtractDocuments(floatingPane.IViewContainer); floatingPane.Close(); } break; } Application.Current.MainWindow.Activate(); }); }