public DockPanel() { m_extender = new DockPanelExtender(this); m_dragHandler = new DragHandler(this); m_panes = new DockPaneCollection(); m_floatWindows = new FloatWindowCollection(); SetStyle(ControlStyles.ResizeRedraw | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); SuspendLayout(); Font = SystemInformation.MenuFont; m_autoHideWindow = new AutoHideWindow(this); m_autoHideWindow.Visible = false; m_dummyControl = new DummyControl(); m_dummyControl.Bounds = Rectangle.Empty; m_dockWindows = new DockWindowCollection(this); Controls.AddRange(new Control[] { m_autoHideWindow, m_dummyControl, DockWindows[DockState.Document], DockWindows[DockState.DockLeft], DockWindows[DockState.DockRight], DockWindows[DockState.DockTop], DockWindows[DockState.DockBottom] }); m_localWindowsHook = new LocalWindowsHook(HookType.WH_CALLWNDPROCRET); m_localWindowsHook.HookInvoked += new LocalWindowsHook.HookEventHandler(this.HookEventHandler); m_localWindowsHook.Install(); m_dummyContent = new DockContent(); ResumeLayout(); }
internal void TestDrop(DragHandler dragHandler, Point pt) { if (DockArea.Width <= 0 || DockArea.Height <= 0) { return; } Point ptClient = PointToClient(pt); int dragSize = MeasurePane.DragSize; Rectangle rectDoc = DocumentRectangle; if (ptClient.Y - rectDoc.Top >= 0 && ptClient.Y - rectDoc.Top < dragSize && DockWindows[DockState.DockTop].DisplayingList.Count == 0 && dragHandler.IsDockStateValid(DockState.DockTop)) { dragHandler.DropTarget.SetDropTarget(this, DockStyle.Top); } else if (rectDoc.Bottom - ptClient.Y >= 0 && rectDoc.Bottom - ptClient.Y < dragSize && DockWindows[DockState.DockBottom].DisplayingList.Count == 0 && dragHandler.IsDockStateValid(DockState.DockBottom)) { dragHandler.DropTarget.SetDropTarget(this, DockStyle.Bottom); } else if (rectDoc.Right - ptClient.X >= 0 && rectDoc.Right - ptClient.X < dragSize && DockWindows[DockState.DockRight].DisplayingList.Count == 0 && dragHandler.IsDockStateValid(DockState.DockRight)) { dragHandler.DropTarget.SetDropTarget(this, DockStyle.Right); } else if (ptClient.X - rectDoc.Left >= 0 && ptClient.X - rectDoc.Left < dragSize && DockWindows[DockState.DockLeft].DisplayingList.Count == 0 && dragHandler.IsDockStateValid(DockState.DockLeft)) { dragHandler.DropTarget.SetDropTarget(this, DockStyle.Left); } else if (((ptClient.Y - rectDoc.Top >= dragSize && ptClient.Y - rectDoc.Top < 2 * dragSize) || (rectDoc.Bottom - ptClient.Y >= dragSize && rectDoc.Bottom - ptClient.Y < 2 * dragSize) || (rectDoc.Right - ptClient.X >= dragSize && rectDoc.Right - ptClient.X < 2 * dragSize) || (ptClient.X - rectDoc.Left >= dragSize && ptClient.X - rectDoc.Left < 2 * dragSize)) && DockWindows[DockState.Document].DisplayingList.Count == 0 && dragHandler.IsDockStateValid(DockState.Document)) { dragHandler.DropTarget.SetDropTarget(this, DockStyle.Fill); } else { return; } if (dragHandler.DropTarget.SameAsOldValue) { return; } Rectangle rect = DockArea; if (dragHandler.DropTarget.Dock == DockStyle.Top) { rect.Height = (int)(DockArea.Height * DockTopPortion); } else if (dragHandler.DropTarget.Dock == DockStyle.Bottom) { rect.Height = (int)(DockArea.Height * DockBottomPortion); rect.Y = DockArea.Bottom - rect.Height; } else if (dragHandler.DropTarget.Dock == DockStyle.Left) { rect.Width = (int)(DockArea.Width * DockLeftPortion); } else if (dragHandler.DropTarget.Dock == DockStyle.Right) { rect.Width = (int)(DockArea.Width * DockRightPortion); rect.X = DockArea.Right - rect.Width; } else if (dragHandler.DropTarget.Dock == DockStyle.Fill) { rect = DocumentRectangle; } rect.Location = PointToScreen(rect.Location); dragHandler.DragOutline = DrawHelper.CreateDragOutline(rect, dragSize); }