Пример #1
0
        /// <summary>
        /// Force the sizes of the window
        /// </summary>
        /// <param name="x">x position of the window</param>
        /// <param name="y">y position of the window</param>
        /// <param name="width">length of the window</param>
        /// <param name="height">height of the window</param>
        /// <param name="specified">size mode</param>
        protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
        {
            if (_resizeIsLocked)
            {
                if (EnumUtility.Contains(specified, BoundsSpecified.Width))
                {
                    width = _lockedBounds.Width;
                }

                if (EnumUtility.Contains(specified, BoundsSpecified.Height))
                {
                    height = _lockedBounds.Height;
                }
            }

            base.SetBoundsCore(x, y, width, height, specified);
        }
Пример #2
0
        /// <summary>
        /// Show the dock guiders buttons
        /// </summary>
        /// <param name="allowedDockMode">allowed dock mode. Guiders will be shown depending on this mode.</param>
        /// <param name="screenClientBounds">screen client bounds of the container</param>
        public void ShowDockGuiders(zDockMode allowedDockMode, Rectangle screenClientBounds)
        {
            if (allowedDockMode == zDockMode.None)
            {
                HideDockGuiders();
                return;
            }

            if (_lastAllowedDock == allowedDockMode && _lastScreenClientBounds == screenClientBounds)
            {
                return;
            }

            _lastAllowedDock        = allowedDockMode;
            _lastScreenClientBounds = screenClientBounds;

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

            Point leftPosition1   = new Point(12, center.Y - _dockLeftGuider1.Height / 2);
            Point topPosition1    = new Point(center.X - _dockTopGuider1.Width / 2, 12);
            Point rightPosition1  = new Point(width - _dockRightGuider1.Width - 12, center.Y - _dockRightGuider1.Height / 2);
            Point bottomPosition1 = new Point(center.X - _dockBottomGuider1.Width / 2, height - _dockBottomGuider1.Height - 12);

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

            Point leftPosition2   = new Point(fillPosition.X - _dockLeftGuider2.Width + 7, center.Y - _dockLeftGuider2.Height / 2);
            Point topPosition2    = new Point(center.X - _dockTopGuider2.Width / 2 - 1, fillPosition.Y - _dockTopGuider2.Height + 7);
            Point rightPosition2  = new Point(fillPosition.X + _dockFillGuider.Width - 7, center.Y - _dockRightGuider2.Height / 2);
            Point bottomPosition2 = new Point(center.X - _dockBottomGuider2.Width / 2, fillPosition.Y + _dockBottomGuider2.Height + 7);

            leftPosition1.Offset(offset);
            rightPosition1.Offset(offset);
            topPosition1.Offset(offset);
            bottomPosition1.Offset(offset);
            fillPosition.Offset(offset);
            leftPosition2.Offset(offset);
            rightPosition2.Offset(offset);
            topPosition2.Offset(offset);
            bottomPosition2.Offset(offset);

            _dockLeftGuider1.Location   = leftPosition1;
            _dockRightGuider1.Location  = rightPosition1;
            _dockTopGuider1.Location    = topPosition1;
            _dockBottomGuider1.Location = bottomPosition1;
            _dockFillGuider.Location    = fillPosition;
            _dockLeftGuider2.Location   = leftPosition2;
            _dockRightGuider2.Location  = rightPosition2;
            _dockTopGuider2.Location    = topPosition2;
            _dockBottomGuider2.Location = bottomPosition2;

            _dockFillGuider.Show();

            bool showLeft = EnumUtility.Contains(allowedDockMode, zDockMode.Left);

            _dockLeftGuider1.Visible = showLeft;
            _dockLeftGuider2.Visible = showLeft;

            bool showRight = EnumUtility.Contains(allowedDockMode, zDockMode.Right);

            _dockRightGuider1.Visible = showRight;
            _dockRightGuider2.Visible = showRight;

            bool showTop = EnumUtility.Contains(allowedDockMode, zDockMode.Top);

            _dockTopGuider1.Visible = showTop;
            _dockTopGuider2.Visible = showTop;

            bool showBottom = EnumUtility.Contains(allowedDockMode, zDockMode.Bottom);

            _dockBottomGuider1.Visible = showBottom;
            _dockBottomGuider2.Visible = showBottom;

            _dockFillGuider.ShowFillPreview = EnumUtility.Contains(allowedDockMode, zDockMode.Fill);

            if (VisibleChanged != null)
            {
                VisibleChanged(this, EventArgs.Empty);
            }
        }