private void InternalConstruct(IDockContent content, DockState dockState, bool flagBounds, Rectangle floatWindowBounds, DockPane prevPane, DockAlignment alignment, double proportion, bool show) { if (dockState == DockState.Hidden || dockState == DockState.Unknown) { throw new ArgumentException(Strings.DockPane_SetDockState_InvalidState); } if (content == null) { throw new ArgumentNullException(Strings.DockPane_Constructor_NullContent); } if (content.DockHandler.DockPanel == null) { throw new ArgumentException(Strings.DockPane_Constructor_NullDockPanel); } SuspendLayout(); SetStyle(ControlStyles.Selectable, false); m_isFloat = (dockState == DockState.Float); m_contents = new DockContentCollection(); m_displayingContents = new DockContentCollection(this); m_dockPanel = content.DockHandler.DockPanel; m_dockPanel.AddPane(this); m_splitter = new SplitterControl(this); m_nestedDockingStatus = new NestedDockingStatus(this); m_captionControl = DockPanel.DockPaneCaptionFactory.CreateDockPaneCaption(this); m_tabStripControl = DockPanel.DockPaneStripFactory.CreateDockPaneStrip(this); Controls.AddRange(new Control[] { m_captionControl, m_tabStripControl }); DockPanel.SuspendLayout(true); if (flagBounds) { FloatWindow = DockPanel.FloatWindowFactory.CreateFloatWindow(DockPanel, this, floatWindowBounds); } else if (prevPane != null) { DockTo(prevPane.NestedPanesContainer, prevPane, alignment, proportion); } SetDockState(dockState); if (show) { content.DockHandler.Pane = this; } else if (this.IsFloat) { content.DockHandler.FloatPane = this; } else { content.DockHandler.PanelPane = this; } ResumeLayout(); DockPanel.ResumeLayout(true, true); }
public void DockTo(DockPane pane, DockStyle dockStyle, int contentIndex) { checked { if (dockStyle == DockStyle.Fill) { bool flag = this.Pane == pane; if (!flag) { this.Pane = pane; } if (contentIndex == -1 || !flag) { pane.SetContentIndex(this.Content, contentIndex); } else { DockContentCollection contents = pane.Contents; int num = contents.IndexOf(this.Content); int num2 = contentIndex; if (num < num2) { num2++; if (num2 > contents.Count - 1) { num2 = -1; } } pane.SetContentIndex(this.Content, num2); } } else { DockPane dockPane = this.DockPanel.DockPaneFactory.CreateDockPane(this.Content, pane.DockState, true); INestedPanesContainer nestedPanesContainer = pane.NestedPanesContainer; if (dockStyle == DockStyle.Left) { dockPane.DockTo(nestedPanesContainer, pane, DockAlignment.Left, 0.5); } else { if (dockStyle == DockStyle.Right) { dockPane.DockTo(nestedPanesContainer, pane, DockAlignment.Right, 0.5); } else { if (dockStyle == DockStyle.Top) { dockPane.DockTo(nestedPanesContainer, pane, DockAlignment.Top, 0.5); } else { if (dockStyle == DockStyle.Bottom) { dockPane.DockTo(nestedPanesContainer, pane, DockAlignment.Bottom, 0.5); } } } } dockPane.DockState = pane.DockState; } } }
protected override void WndProc(ref Message m) { if (m.Msg == (int)Win32.Msgs.WM_NCLBUTTONDOWN) { if (IsDisposed) { return; } uint result = NativeMethods.SendMessage(this.Handle, (int)Win32.Msgs.WM_NCHITTEST, 0, (uint)m.LParam); if (result == 2 && DockPanel.AllowEndUserDocking && this.AllowEndUserDocking) // HITTEST_CAPTION { Activate(); m_dockPanel.BeginDrag(this); } else { base.WndProc(ref m); } return; } else if (m.Msg == (int)Win32.Msgs.WM_NCRBUTTONDOWN) { uint result = NativeMethods.SendMessage(this.Handle, (int)Win32.Msgs.WM_NCHITTEST, 0, (uint)m.LParam); if (result == 2) // HITTEST_CAPTION { DockPane theOnlyPane = (VisibleNestedPanes.Count == 1) ? VisibleNestedPanes[0] : null; if (theOnlyPane != null && theOnlyPane.ActiveContent != null) { theOnlyPane.ShowTabPageContextMenu(this, PointToClient(Control.MousePosition)); return; } } base.WndProc(ref m); return; } else if (m.Msg == (int)Win32.Msgs.WM_CLOSE) { if (NestedPanes.Count == 0) { base.WndProc(ref m); return; } for (int i = NestedPanes.Count - 1; i >= 0; i--) { DockContentCollection contents = NestedPanes[i].Contents; for (int j = contents.Count - 1; j >= 0; j--) { IDockContent content = contents[j]; if (content.DockHandler.DockState != DockState.Float) { continue; } if (!content.DockHandler.CloseButton) { continue; } if (content.DockHandler.HideOnClose) { content.DockHandler.Hide(); } else { content.DockHandler.Close(); } } } return; } else if (m.Msg == (int)Win32.Msgs.WM_NCLBUTTONDBLCLK) { uint result = NativeMethods.SendMessage(this.Handle, (int)Win32.Msgs.WM_NCHITTEST, 0, (uint)m.LParam); if (result != 2) // HITTEST_CAPTION { base.WndProc(ref m); return; } DockPanel.SuspendLayout(true); // Restore to panel foreach (DockPane pane in NestedPanes) { if (pane.DockState != DockState.Float) { continue; } pane.RestoreToPanel(); } DockPanel.ResumeLayout(true, true); return; } else if (m.Msg == WM_CHECKDISPOSE) { if (NestedPanes.Count == 0) { Dispose(); } return; } base.WndProc(ref m); }
protected override void WndProc(ref Message m) { checked { if (m.Msg == 161) { if (!base.IsDisposed) { uint num = NativeMethods.SendMessage(base.Handle, 132, 0u, (uint)((int)m.LParam)); if (num == 2u && this.DockPanel.AllowEndUserDocking && this.AllowEndUserDocking) { base.Activate(); this.m_dockPanel.BeginDrag(this); } else { base.WndProc(ref m); } } } else { if (m.Msg == 164) { uint num = NativeMethods.SendMessage(base.Handle, 132, 0u, (uint)((int)m.LParam)); if (num == 2u) { DockPane dockPane = (this.VisibleNestedPanes.Count == 1) ? this.VisibleNestedPanes[0] : null; if (dockPane != null && dockPane.ActiveContent != null) { dockPane.ShowTabPageContextMenu(this, base.PointToClient(Control.MousePosition)); return; } } base.WndProc(ref m); } else { if (m.Msg == 16) { if (this.NestedPanes.Count == 0) { base.WndProc(ref m); } else { for (int i = this.NestedPanes.Count - 1; i >= 0; i--) { DockContentCollection contents = this.NestedPanes[i].Contents; for (int j = contents.Count - 1; j >= 0; j--) { IDockContent dockContent = contents[j]; if (dockContent.DockHandler.DockState == DockState.Float) { if (dockContent.DockHandler.CloseButton) { if (dockContent.DockHandler.HideOnClose) { dockContent.DockHandler.Hide(); } else { dockContent.DockHandler.Close(); } } } } } } } else { if (m.Msg == 163) { uint num = NativeMethods.SendMessage(base.Handle, 132, 0u, (uint)((int)m.LParam)); if (num != 2u) { base.WndProc(ref m); } else { this.DockPanel.SuspendLayout(true); foreach (DockPane current in this.NestedPanes) { if (current.DockState == DockState.Float) { current.RestoreToPanel(); } } this.DockPanel.ResumeLayout(true, true); } } else { if (m.Msg == 1025) { if (this.NestedPanes.Count == 0) { base.Dispose(); } } else { base.WndProc(ref m); } } } } } } }