示例#1
0
        public static FloatWindow FloatWindowAtPoint(Point pt, DockPanel dockPanel)
        {
            if (!NativeMethods.ShouldUseWin32())
            {
                return(null);
            }
            for (Control control = Win32Helper.ControlAtPoint(pt); control != null; control = control.Parent)
            {
                FloatWindow floatWindow = control as FloatWindow;
                if (floatWindow != null && floatWindow.DockPanel == dockPanel)
                {
                    return(floatWindow);
                }
            }

            return(null);
        }
示例#2
0
 internal void TestDrop(IDockDragSource dragSource, DockOutlineBase dockOutline)
 {
     if (this.VisibleNestedPanes.Count == 1)
     {
         DockPane pane = this.VisibleNestedPanes[0];
         if (!dragSource.CanDockTo(pane))
         {
             return;
         }
         Point ptMouse = MousePosition;
         uint  lParam  = Win32Helper.MakeLong(ptMouse.X, ptMouse.Y);
         if (NativeMethods.SendMessage(this.Handle, (int)Msgs.WM_NCHITTEST, 0, lParam) == (uint)HitTest.HTCAPTION)
         {
             dockOutline.Show(this.VisibleNestedPanes[0], -1);
         }
     }
 }
示例#3
0
        internal void TestDrop(IDockDragSource dragSource, DockOutlineBase dockOutline)
        {
            if (VisibleNestedPanes.Count == 1)
            {
                DockPane pane = VisibleNestedPanes[0];
                if (!dragSource.CanDockTo(pane))
                {
                    return;
                }

                Point ptMouse = Control.MousePosition;
                uint  lParam  = Win32Helper.MakeLong(ptMouse.X, ptMouse.Y);
                if (NativeMethods.SendMessage(Handle, (int)Win32.Msgs.WM_NCHITTEST, IntPtr.Zero, (IntPtr)lParam) == (IntPtr)Win32.HitTest.HTCAPTION)
                {
                    dockOutline.Show(VisibleNestedPanes[0], -1);
                }
            }
        }
示例#4
0
        public static DockPane PaneAtPoint(Point pt, DockPanel dockPanel)
        {
            for (Control control = Win32Helper.ControlAtPoint(pt); control != null; control = control.Parent)
            {
                IDockContent content = control as IDockContent;
                if (content != null && content.DockHandler.DockPanel == dockPanel)
                {
                    return(content.DockHandler.Pane);
                }

                DockPane pane = control as DockPane;
                if (pane != null && pane.DockPanel == dockPanel)
                {
                    return(pane);
                }
            }

            return(null);
        }
示例#5
0
        public static DockPane PaneAtPoint(Point pt, DockPanel dockPanel)
        {
            if (!Win32Helper.IsRunningOnMono)
            {
                for (Control control = Win32Helper.ControlAtPoint(pt); control != null; control = control.Parent)
                {
                    if (control is IDockContent content && content.DockHandler.DockPanel == dockPanel)
                    {
                        return(content.DockHandler.Pane);
                    }

                    if (control is DockPane pane && pane.DockPanel == dockPanel)
                    {
                        return(pane);
                    }
                }
            }

            return(null);
        }
示例#6
0
        internal void TestDrop(DockHelper.CursorPoint info, DockOutlineBase dockOutline)
        {
            if (VisibleNestedPanes.Count == 1)
            {
                DockPane pane = VisibleNestedPanes[0];
                if (!info.DragSource.CanDockTo(pane))
                {
                    return;
                }

                Point ptMouse = info.Cursor;
                uint  lParam  = Win32Helper.MakeLong(ptMouse.X, ptMouse.Y);
                if (!Win32Helper.IsRunningOnMono)
                {
                    if (NativeMethods.SendMessage(Handle, (int)Win32.Msgs.WM_NCHITTEST, 0, lParam) == (uint)Win32.HitTest.HTCAPTION)
                    {
                        dockOutline.Show(VisibleNestedPanes[0], -1);
                    }
                }
            }
        }
示例#7
0
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
            case (int)Win32.Msgs.WM_NCLBUTTONDOWN:
            {
                if (IsDisposed)
                {
                    return;
                }

                uint result = Win32Helper.IsRunningOnMono ? 0 : 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;
            }

            case (int)Win32.Msgs.WM_NCRBUTTONDOWN:
            {
                uint result = Win32Helper.IsRunningOnMono ? Win32Helper.HitTestCaption(this) : 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;
            }

            case (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;

            case (int)Win32.Msgs.WM_NCLBUTTONDBLCLK:
            {
                uint result = !DoubleClickTitleBarToDock || Win32Helper.IsRunningOnMono
                            ? Win32Helper.HitTestCaption(this)
                            : 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;
            }

            case WM_CHECKDISPOSE:
                if (NestedPanes.Count == 0)
                {
                    Dispose();
                }
                return;
            }

            base.WndProc(ref m);
        }