示例#1
0
        /// <summary>
        /// Create floating container for the view
        /// </summary>
        /// <param name="view">view for which to create floating container</param>
        /// <param name="bounds">bounds of the floating container</param>
        /// <returns>floating container</returns>
        public DockingContainer CreateFloatingContainer(FormsTabbedView view, Rectangle bounds)
        {
            DockingContainer container = new DockingContainer();

            _host.AddFirst(container);

            container.Bounds = bounds;

            container.SetModeSingleChild(view);

            if (EnumUtility.Contains(view.AllowedDock, DockAllowed.None))
            {
                SetViewDock(view, DockStyle.None, DockStyle.None, DockableMode.None);
            }
            else if (EnumUtility.Contains(view.AllowedDock, DockAllowed.Left))
            {
                DockControl(container, null, DockStyle.Left, DockableMode.Outer);
            }
            else if (EnumUtility.Contains(view.AllowedDock, DockAllowed.Right))
            {
                DockControl(container, null, DockStyle.Right, DockableMode.Outer);
            }
            else if (EnumUtility.Contains(view.AllowedDock, DockAllowed.Top))
            {
                DockControl(container, null, DockStyle.Top, DockableMode.Outer);
            }
            else if (EnumUtility.Contains(view.AllowedDock, DockAllowed.Bottom))
            {
                DockControl(container, null, DockStyle.Bottom, DockableMode.Outer);
            }
            else if (EnumUtility.Contains(view.AllowedDock, DockAllowed.Fill))
            {
                DockControl(container, null, DockStyle.Fill, DockableMode.Inner);
            }
            else
            {
                _host.Remove(container);
                throw new NotSupportedException("Err");   // invalid allowed dock
            }

            return(container);
        }
示例#2
0
        /// <summary>
        /// Update the bounds of the buttons
        /// </summary>
        /// <param name="allowedDockMode">allowed dock mode</param>
        /// <param name="viewScreenRectangle">view rectanlge in the center of which the buttons to dock will be shown (in screen coordinates)</param>
        public void UpdateGuiderBounds(DockAllowed allowedDockMode, Rectangle viewScreenRectangle)
        {
            ValidateNotDisposed();

            Rectangle viewRectangle = _host.RectangleToClient(viewScreenRectangle);

            if (_lastAllowedDockMode == allowedDockMode && _lastViewRectangle == viewRectangle)
            {
                return;
            }

            _lastViewRectangle   = viewRectangle;
            _lastAllowedDockMode = allowedDockMode;

            int   width  = viewRectangle.Width;
            int   height = viewRectangle.Height;
            Point center = new Point(width / 2, height / 2);
            Point offset = viewRectangle.Location;

            Point fillPosition = new Point(center.X - _dockFillGuider.Width / 2, center.Y - _dockFillGuider.Height / 2);

            Point leftPosition   = new Point(fillPosition.X - _dockLeftGuider.Width + 7, center.Y - _dockLeftGuider.Height / 2);
            Point topPosition    = new Point(center.X - _dockTopGuider.Width / 2 - 1, fillPosition.Y - _dockTopGuider.Height + 7);
            Point rightPosition  = new Point(fillPosition.X + _dockFillGuider.Width - 7, center.Y - _dockRightGuider.Height / 2);
            Point bottomPosition = new Point(center.X - _dockBottomGuider.Width / 2, fillPosition.Y + _dockBottomGuider.Height + 7);

            fillPosition.Offset(offset);
            leftPosition.Offset(offset);
            rightPosition.Offset(offset);
            topPosition.Offset(offset);
            bottomPosition.Offset(offset);

            _dockLeftGuider.Location   = leftPosition;
            _dockRightGuider.Location  = rightPosition;
            _dockTopGuider.Location    = topPosition;
            _dockBottomGuider.Location = bottomPosition;
            _dockFillGuider.Location   = fillPosition;

            bool dockLeftGuiderVisible         = EnumUtility.Contains(allowedDockMode, DockAllowed.Left);
            bool dockRightGuiderVisible        = EnumUtility.Contains(allowedDockMode, DockAllowed.Right);
            bool dockTopGuiderVisible          = EnumUtility.Contains(allowedDockMode, DockAllowed.Top);
            bool dockBottomGuiderVisible       = EnumUtility.Contains(allowedDockMode, DockAllowed.Bottom);
            bool dockFillGuiderShowFillPreview = EnumUtility.Contains(allowedDockMode, DockAllowed.Fill);


            _guiderBounds.X = _dockFillGuider.Left;
            if (dockLeftGuiderVisible)
            {
                _guiderBounds.X = _dockLeftGuider.Left;
            }

            _guiderBounds.Y = _dockFillGuider.Top;
            if (dockTopGuiderVisible)
            {
                _guiderBounds.Y = _dockTopGuider.Top;
            }

            int right = _dockFillGuider.Right;

            if (dockRightGuiderVisible)
            {
                right = _dockRightGuider.Right;
            }
            _guiderBounds.Width = right - _guiderBounds.Left;

            int bottom = _dockFillGuider.Bottom;

            if (dockBottomGuiderVisible)
            {
                bottom = _dockBottomGuider.Bottom;
            }
            _guiderBounds.Height = bottom - _guiderBounds.Top;


            _leftButtonBounds.Location   = leftPosition;
            _rightButtonBounds.Location  = rightPosition;
            _topButtonBounds.Location    = topPosition;
            _bottomButtonBounds.Location = bottomPosition;

            _fillButtonBounds    = _dockFillGuider.FillBounds;
            _fillButtonBounds.X += _dockFillGuider.Left;
            _fillButtonBounds.Y += _dockFillGuider.Top;
        }
示例#3
0
        /// <summary>
        /// Gets the dock result for given screen location
        /// </summary>
        /// <param name="allowedDockMode">allowed dock mode</param>
        /// <param name="screenLocation">screen location</param>
        /// <returns>dock result</returns>
        public GuidedDockResult GetDockResult(DockAllowed allowedDockMode, Point screenLocation)
        {
            ValidateNotDisposed();

            _dockResult.Dock     = DockStyle.None;
            _dockResult.DockMode = DockableMode.Outer;

            Point clientLocation = _host.PointToClient(screenLocation);

            if (_marginGuiders.LeftButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, DockAllowed.Left))
            {
                _dockResult.Dock = DockStyle.Left;
            }
            else if (_marginGuiders.RightButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, DockAllowed.Right))
            {
                _dockResult.Dock = DockStyle.Right;
            }
            else if (_marginGuiders.TopButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, DockAllowed.Top))
            {
                _dockResult.Dock = DockStyle.Top;
            }
            else if (_marginGuiders.BottomButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, DockAllowed.Bottom))
            {
                _dockResult.Dock = DockStyle.Bottom;
            }
            else if (_centerGuider.IsVisible)
            {
                _dockResult.DockMode = DockableMode.Inner;

                if (_centerGuider.LeftButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, DockAllowed.Left))
                {
                    _dockResult.Dock = DockStyle.Left;
                }
                else if (_centerGuider.TopButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, DockAllowed.Top))
                {
                    _dockResult.Dock = DockStyle.Top;
                }
                else if (_centerGuider.RightButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, DockAllowed.Right))
                {
                    _dockResult.Dock = DockStyle.Right;
                }
                else if (_centerGuider.BottomButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, DockAllowed.Bottom))
                {
                    _dockResult.Dock = DockStyle.Bottom;
                }
                else if (_centerGuider.FillButtonBounds.Contains(clientLocation) && EnumUtility.Contains(allowedDockMode, DockAllowed.Fill))
                {
                    _dockResult.Dock = DockStyle.Fill;
                }
            }

            return(_dockResult);
        }