private void OnPageDragStart(Crownwood.DotNetMagic.Controls.TabControl sender,
                                     Crownwood.DotNetMagic.Controls.TabPage movePage,
                                     MouseEventArgs e)
        {
            // Is the user allowed to redock?
            if (DockingManager.AllowRedocking)
            {
                // Use allow to redock this particular content?
                if (this.RedockAllowed)
                {
                    // Event page must specify its Content object
                    Content c = movePage.Tag as Content;

                    // Remember the position of the tab before it is removed
                    _dragPageIndex = _tabControl.TabPages.IndexOf(movePage);

                    // Force the entire window to redraw to ensure the Redocker does not start drawing
                    // the XOR indicator before the window repaints itself. Otherwise the repainted
                    // control will interfere with the XOR indicator.
                    this.Refresh();

                    // Start redocking activity for the single Content of this WindowContent
                    _redocker = Redocker.CreateRedocker(DockingManager.FeedbackStyle, _tabControl,
                                                        c, this, new Point(e.X, e.Y));
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Processes Windows messages.
        /// </summary>
        /// <param name="m">The Windows Message to process. </param>
        protected override void WndProc(ref Message m)
        {
            // Want to notice when the window is maximized
            if (m.Msg == (int)Win32.Msgs.WM_NCLBUTTONDBLCLK)
            {
                // Is the user allowed to redock?
                if (_dockingManager.AllowRedocking)
                {
                    // Redock and kill ourself
                    Restore();

                    // Raise event to indicate a double click occured
                    _dockingManager.OnDoubleClickDock();
                }

                // We do not want to let the base process the message as the
                // restore might fail due to lack of permission to restore to
                // old state.  In that case we do not want to maximize the window
                return;
            }
            else if (m.Msg == (int)Win32.Msgs.WM_NCLBUTTONDOWN)
            {
                if (!_intercept)
                {
                    // Perform a hit test against our own window to determine
                    // which area the mouse press is over at the moment.
                    uint result = User32.SendMessage(this.Handle, (int)Win32.Msgs.WM_NCHITTEST, 0, (uint)m.LParam);

                    // Only want to override the behaviour of moving the window via the caption box
                    if (result == HITTEST_CAPTION)
                    {
                        // Is the user allowed to redock?
                        if (_dockingManager.AllowRedocking)
                        {
                            // Remember new state
                            _intercept = true;

                            // Capture the mouse until the mouse us is received
                            this.Capture = true;

                            // Ensure that we gain focus and look active
                            this.Activate();

                            // Raise event to indicate a floating form has become active
                            _dockingManager.OnFloatingFormActivated(this);

                            // Get mouse position to inscreen coordinates
                            Win32.POINT mousePos;
                            mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU);
                            mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16);

                            // Begin a redocking activity
                            _redocker = Redocker.CreateRedocker(DockingManager.FeedbackStyle,
                                                                this, new Point(mousePos.x - DesktopBounds.X,
                                                                                mousePos.y - DesktopBounds.Y));


                            return;
                        }
                    }
                }
            }
            else if (m.Msg == (int)Win32.Msgs.WM_MOUSEMOVE)
            {
                if (_intercept)
                {
                    Win32.POINT mousePos;
                    mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU);
                    mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16);

                    _redocker.OnMouseMove(new MouseEventArgs(MouseButtons.Left,
                                                             0, mousePos.x, mousePos.y, 0));

                    return;
                }
            }
            else if ((m.Msg == (int)Win32.Msgs.WM_RBUTTONDOWN) ||
                     (m.Msg == (int)Win32.Msgs.WM_MBUTTONDOWN))
            {
                if (_intercept)
                {
                    Win32.POINT mousePos;
                    mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU);
                    mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16);

                    _redocker.QuitTrackingMode(new MouseEventArgs(MouseButtons.Left,
                                                                  0, mousePos.x, mousePos.y, 0));

                    // Release capture
                    this.Capture = false;

                    // Reset state
                    _intercept = false;

                    return;
                }
            }
            else if (m.Msg == (int)Win32.Msgs.WM_LBUTTONUP)
            {
                if (_intercept)
                {
                    Win32.POINT mousePos;
                    mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU);
                    mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16);

                    _redocker.OnMouseUp(new MouseEventArgs(MouseButtons.Left, 0,
                                                           mousePos.x, mousePos.y, 0));

                    // Release capture
                    this.Capture = false;

                    // Reset state
                    _intercept = false;

                    return;
                }
            }
            else if ((m.Msg == (int)Win32.Msgs.WM_NCRBUTTONUP) ||
                     (m.Msg == (int)Win32.Msgs.WM_NCMBUTTONDOWN) ||
                     (m.Msg == (int)Win32.Msgs.WM_NCMBUTTONUP) ||
                     (m.Msg == (int)Win32.Msgs.WM_RBUTTONDOWN) ||
                     (m.Msg == (int)Win32.Msgs.WM_RBUTTONUP) ||
                     (m.Msg == (int)Win32.Msgs.WM_MBUTTONDOWN) ||
                     (m.Msg == (int)Win32.Msgs.WM_MBUTTONUP))
            {
                // Prevent middle and right mouse buttons from interrupting
                // the correct operation of left mouse dragging
                return;
            }
            else if (m.Msg == (int)Win32.Msgs.WM_NCRBUTTONDOWN)
            {
                if (!_intercept)
                {
                    // Get screen coordinates of the mouse
                    Win32.POINT mousePos;
                    mousePos.x = (short)((uint)m.LParam & 0x0000FFFFU);
                    mousePos.y = (short)(uint)(((uint)m.LParam & 0xFFFF0000U) >> 16);

                    // Box to transfer as parameter
                    OnContext(new Point(mousePos.x, mousePos.y));

                    return;
                }
            }

            base.WndProc(ref m);
        }