/// <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();
            }
        }
Example #2
0
        /// <summary>
        /// Dock the form in host
        /// </summary>
        /// <param name="containerToDock">container to dock</param>
        /// <param name="dock">dock</param>
        /// <param name="mode">mode</param>
        private void DockInHost(DockableContainer container, DockStyle dock, zDockMode mode)
        {
            Rectangle availableBounds = FormWrapper.GetFillScreenRectangle(_host);

            container.SingleChild.SaveFloatingSize();
            container.Splitter.Visible = false;

            if (_host.Contains(container.Splitter) == false && dock != DockStyle.Fill)
            {
                _host.AddLast(container.Splitter);
            }

            if (mode == zDockMode.Inner)
            {
                if (dock != DockStyle.Fill)
                {
                    _host.MoveFirst(container);
                    _host.MoveFirst(container.Splitter);
                }
            }
            else
            {
                if (dock != DockStyle.Fill)
                {
                    _host.MoveLast(container.Splitter);
                    _host.MoveLast(container);
                }
            }

            container.Dock = dock;

            if (dock != DockStyle.Fill)
            {
                container.Splitter.Dock    = dock;
                container.Splitter.Visible = true;
            }
            else
            {
                container.SingleChild.ButtonsRenderer = new TopTabButtonRenderer();
            }

            // Must call this again after splitter is docked and made visible, to have proper splitter.
            // Must have this if/else block also before making the splitter visible to prevent flickering
            if (mode == zDockMode.Inner)
            {
                if (dock != DockStyle.Fill)
                {
                    _host.MoveFirst(container);
                    _host.MoveFirst(container.Splitter);

                    if (availableBounds.IsEmpty == false)
                    {
                        if (dock == DockStyle.Left || dock == DockStyle.Right)
                        {
                            if (container.Width >= availableBounds.Width - MinAvailableSize)
                            {
                                container.Width = availableBounds.Width - MinAvailableSize;
                            }
                        }
                        else if (dock == DockStyle.Top || dock == DockStyle.Bottom)
                        {
                            if (container.Height >= availableBounds.Height - MinAvailableSize)
                            {
                                container.Height = availableBounds.Height - MinAvailableSize;
                            }
                        }
                    }
                }
            }
            else
            {
                if (dock != DockStyle.Fill)
                {
                    _host.MoveLast(container.Splitter);
                    _host.MoveLast(container);
                }
            }

            SetViewDock(container.SingleChild, dock, dock, mode);
        }