コード例 #1
0
        /// <summary>
        /// End window movement
        /// </summary>
        public void EndWindowMovement()
        {
            if (_movedWindow == null)
            {
                return;
            }

            Point        screenLocation = Control.MousePosition;
            zAllowedDock allowedDock    = _allowedDock;

            if (GetContainerUnderMouse(screenLocation) != null)
            {
                allowedDock = zAllowedDock.All;
            }

            GuidedDockResult result       = _guider.GetDockResult(allowedDock, screenLocation);
            Control          movedControl = _movedWindow;

            StopMovement();

            _movedWindow = null;

            EventHandler <DockControlEventArgs> handler = ApplyDock;

            if (handler != null && result.Dock != DockStyle.None)
            {
                DockControlEventArgs args = new DockControlEventArgs(movedControl, result.Dock, result.DockMode);
                handler(this, args);
            }
        }
コード例 #2
0
        /// <summary>
        /// Move a window using mouse
        /// </summary>
        public void MoveWindowByMouse()
        {
            if (_movedWindow == null)
            {
                return;
            }

            zAllowedDock      allowedDock         = _allowedDock;
            Point             screenLocation      = Control.MousePosition;
            DockableContainer containerUnderMouse = GetContainerUnderMouse(screenLocation);

            Rectangle fillRectangle = FormWrapper.GetFillRectangleFromPoint(screenLocation, containerUnderMouse, _host);

            if (fillRectangle.IsEmpty)
            {
                _guider.HideCenterGuider();
            }
            else
            {
                if (containerUnderMouse == null)
                {
                    _guider.ShowCenterGuider(allowedDock, fillRectangle);
                }
                else
                {
                    allowedDock = zAllowedDock.All;
                    _guider.ShowCenterGuider(allowedDock, fillRectangle);
                }
            }


            GuidedDockResult result = _guider.GetDockResult(allowedDock, screenLocation);

            if (result.DockMode == zDockMode.Outer && result.Dock != DockStyle.None)
            {
                Rectangle bounds = OuterDockPreviewEngine.GetPreviewBounds(result.Dock, _host, _movedWindow);
                _guider.ShowPreviewPanel(bounds);
            }
            else if (result.DockMode == zDockMode.Inner && result.Dock != DockStyle.None)
            {
                Rectangle freeBounds = FormWrapper.GetFillScreenRectangle(_host);
                Rectangle bounds     = InnerDockPreviewEngine.GetPreviewBounds(result.Dock, _movedWindow, containerUnderMouse, freeBounds);
                if (bounds.IsEmpty)
                {
                    _guider.HidePreviewPanel();
                }
                else
                {
                    _guider.ShowPreviewPanel(bounds);
                }
            }
            else
            {
                _guider.HidePreviewPanel();
            }
        }