public void ForceDocking(DockPane targetDockPane, FloatingWindow floatingWindow, EDock dock) { try { DockPane dockPane = floatingWindow.MainDockPane; dockPane.RemoveSelf(); if (dockPane != null) { targetDockPane.Docking(dockPane, dock); floatingWindow.Close(); } } catch { return; } }
public void SetPos(int monitorIdx, Point pos, int rowHeight, int rows, string size, EDock dock) { var mon = Screen.Default.GetMonitorGeometry(monitorIdx); if (size.EndsWith("%")) { var widthPercent = double.Parse(size.Substring(0, size.Length - 1), System.Globalization.CultureInfo.InvariantCulture); width = (int)(((double)mon.Width / 100) * widthPercent); } else { width = int.Parse(size); } this.rows = rows; this.rowHeight = rowHeight; panelSize = rowHeight * rows; height = panelSize; if (dock.HasFlag(EDock.Top)) { pos.Y = 0; } if (dock.HasFlag(EDock.Bottom)) { pos.Y = mon.Height - panelSize; } win.Move(pos.X, pos.Y); win.SetDefaultSize(width, height); win.SetSizeRequest(width, height); }
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); }