コード例 #1
0
        private void Content_OnEndDrag(bool abort)
        {
            User32.SetCursor(DragControl.Cursor.Handle);

            if (abort)
            {
                return;
            }

            IDockableWindow content = DragControl as IDockableWindow;

            if (!DockOutline.FloatWindowBounds.IsEmpty)
            {
                DockPane pane = content.DockHandler.DockPanel.DockPaneFactory.CreateDockPane(content, DockOutline.FloatWindowBounds, true);
                pane.Activate();
            }
            else if (DockOutline.DockTo is DockPane)
            {
                DockPane paneTo = DockOutline.DockTo as DockPane;

                if (DockOutline.Dock == DockStyle.Fill)
                {
                    bool samePane = (content.DockHandler.Pane == paneTo);
                    if (!samePane)
                    {
                        content.DockHandler.Pane = paneTo;
                    }

                    if (DockOutline.ContentIndex == -1 || !samePane)
                    {
                        paneTo.SetContentIndex(content, DockOutline.ContentIndex);
                    }
                    else
                    {
                        DockContentCollection contents = paneTo.Contents;
                        int oldIndex = contents.IndexOf(content);
                        int newIndex = DockOutline.ContentIndex;
                        if (oldIndex < newIndex)
                        {
                            newIndex += 1;
                            if (newIndex > contents.Count - 1)
                            {
                                newIndex = -1;
                            }
                        }
                        paneTo.SetContentIndex(content, newIndex);
                    }

                    content.DockHandler.Activate();
                }
                else
                {
                    DockPane           pane      = content.DockHandler.DockPanel.DockPaneFactory.CreateDockPane(content, paneTo.DockState, true);
                    IDockListContainer container = paneTo.DockListContainer;
                    if (DockOutline.Dock == DockStyle.Left)
                    {
                        pane.AddToDockList(container, paneTo, DockAlignment.Left, 0.5);
                    }
                    else if (DockOutline.Dock == DockStyle.Right)
                    {
                        pane.AddToDockList(container, paneTo, DockAlignment.Right, 0.5);
                    }
                    else if (DockOutline.Dock == DockStyle.Top)
                    {
                        pane.AddToDockList(container, paneTo, DockAlignment.Top, 0.5);
                    }
                    else if (DockOutline.Dock == DockStyle.Bottom)
                    {
                        pane.AddToDockList(container, paneTo, DockAlignment.Bottom, 0.5);
                    }

                    pane.DockState = paneTo.DockState;
                    pane.Activate();
                }
            }
            else if (DockOutline.DockTo is DockContainer)
            {
                DockPane      pane;
                DockContainer dockPanel = content.DockHandler.DockPanel;

                SetDockWindow();
                if (DockOutline.Dock == DockStyle.Top)
                {
                    pane = dockPanel.DockPaneFactory.CreateDockPane(content, DockState.DockTop, true);
                }
                else if (DockOutline.Dock == DockStyle.Bottom)
                {
                    pane = dockPanel.DockPaneFactory.CreateDockPane(content, DockState.DockBottom, true);
                }
                else if (DockOutline.Dock == DockStyle.Left)
                {
                    pane = dockPanel.DockPaneFactory.CreateDockPane(content, DockState.DockLeft, true);
                }
                else if (DockOutline.Dock == DockStyle.Right)
                {
                    pane = dockPanel.DockPaneFactory.CreateDockPane(content, DockState.DockRight, true);
                }
                else if (DockOutline.Dock == DockStyle.Fill)
                {
                    pane = dockPanel.DockPaneFactory.CreateDockPane(content, DockState.Document, true);
                }
                else
                {
                    return;
                }

                pane.Activate();
            }
        }
コード例 #2
0
        private void InternalConstruct(IDockableWindow 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(ResourceHelper.GetString("DockPane.DockState.InvalidState"));
            }

            if (content == null)
            {
                throw new ArgumentNullException(ResourceHelper.GetString("DockPane.Constructor.NullContent"));
            }

            if (content.DockHandler.DockPanel == null)
            {
                throw new ArgumentException(ResourceHelper.GetString("DockPane.Constructor.NullDockPanel"));
            }


            SuspendLayout();
            SetStyle(ControlStyles.Selectable, false);

            m_isFloat = (dockState == DockState.Float);

            m_contents           = new DockContentCollection();
            m_displayingContents = new DockContentCollection(this);
            m_tabs      = new DockPaneTabCollection(this);
            m_dockPanel = content.DockHandler.DockPanel;
            m_dockPanel.AddPane(this);

            m_splitter = new DockPaneSplitter(this);

            m_nestedDockingStatus = new NestedDockingStatus(this);

            m_autoHidePane    = DockPanel.AutoHidePaneFactory.CreateAutoHidePane(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)
            {
                AddToDockList(prevPane.DockListContainer, 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);
        }
コード例 #3
0
        /// <exclude/>
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == (int)Win32.Msgs.WM_NCLBUTTONDOWN)
            {
                if (IsDisposed)
                {
                    return;
                }

                uint result = User32.SendMessage(this.Handle, (int)Win32.Msgs.WM_NCHITTEST, 0, (uint)m.LParam);
                if (result == 2 && DockPanel.AllowRedocking && this.AllowRedocking)                     // HITTEST_CAPTION
                {
                    Activate();
                    m_dockPanel.DragHandler.BeginDragFloatWindow(this);
                }
                else
                {
                    base.WndProc(ref m);
                }

                return;
            }
            else if (m.Msg == (int)Win32.Msgs.WM_CLOSE)
            {
                if (DockList.Count == 0)
                {
                    base.WndProc(ref m);
                    return;
                }

                for (int i = DockList.Count - 1; i >= 0; i--)
                {
                    DockContentCollection contents = DockList[i].Contents;
                    for (int j = contents.Count - 1; j >= 0; j--)
                    {
                        IDockableWindow 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 = User32.SendMessage(this.Handle, (int)Win32.Msgs.WM_NCHITTEST, 0, (uint)m.LParam);
                if (result != 2)                        // HITTEST_CAPTION
                {
                    base.WndProc(ref m);
                    return;
                }

                Visible = false;
                DockPanel.SuspendLayout(true);

                // Restore to panel
                foreach (DockPane pane in DockList)
                {
                    if (pane.DockState != DockState.Float)
                    {
                        continue;
                    }
                    pane.RestoreToPanel();
                }

                DockPanel.ResumeLayout(true, true);
                if (Visible != (DisplayingList.Count > 0))
                {
                    Visible = (DisplayingList.Count > 0);
                }
                return;
            }
            else if (m.Msg == (int)Win32.Msgs.WM_WINDOWPOSCHANGING)
            {
                int offset = (int)Marshal.OffsetOf(typeof(Win32.WINDOWPOS), "flags");
                int flags  = Marshal.ReadInt32(m.LParam, offset);
                Marshal.WriteInt32(m.LParam, offset, flags | (int)Win32.FlagsSetWindowPos.SWP_NOCOPYBITS);
            }
            else if (m.Msg == WM_CHECKDISPOSE)
            {
                if (DockList.Count == 0)
                {
                    Dispose();
                }

                return;
            }

            base.WndProc(ref m);
        }
コード例 #4
0
ファイル: DockPane.cs プロジェクト: viticm/pap2
		private void InternalConstruct(IDockableWindow 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(ResourceHelper.GetString("DockPane.DockState.InvalidState"));

			if (content == null)
				throw new ArgumentNullException(ResourceHelper.GetString("DockPane.Constructor.NullContent"));

			if (content.DockHandler.DockPanel == null)
				throw new ArgumentException(ResourceHelper.GetString("DockPane.Constructor.NullDockPanel"));


			SuspendLayout();
			SetStyle(ControlStyles.Selectable, false);

			m_isFloat = (dockState == DockState.Float);

			m_contents = new DockContentCollection();
			m_displayingContents = new DockContentCollection(this);
			m_tabs = new DockPaneTabCollection(this);
			m_dockPanel = content.DockHandler.DockPanel;
			m_dockPanel.AddPane(this);

			m_splitter = new DockPaneSplitter(this);

			m_nestedDockingStatus = new NestedDockingStatus(this);

			m_autoHidePane = DockPanel.AutoHidePaneFactory.CreateAutoHidePane(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)
				AddToDockList(prevPane.DockListContainer, 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);
		}