Example #1
0
        /// <summary>
        /// GEt fill screen rectangle
        /// </summary>
        /// <param name="wrapper">wrapper</param>
        /// <returns></returns>
        public static Rectangle GetFillScreenRectangle(FormWrapper wrapper)
        {
            Rectangle clientArea = wrapper.RectangleToClient(GetScreenClientRectangle(wrapper._host));

            int x1 = clientArea.Left;
            int x2 = clientArea.Right;
            int y1 = clientArea.Top;
            int y2 = clientArea.Bottom;

            for (int index = 0; index < wrapper.ControlsCount; index++)
            {
                Control control = wrapper.GetControlAt(index);
                if (control.Dock == DockStyle.None || control.Visible == false)
                {
                    continue;
                }

                if (control.Dock == DockStyle.Left)
                {
                    x1 = Math.Max(x1, control.Right);
                }
                else if (control.Dock == DockStyle.Right)
                {
                    x2 = Math.Min(x2, control.Left);
                }
                else if (control.Dock == DockStyle.Top)
                {
                    y1 = Math.Max(y1, control.Bottom);
                }
                else if (control.Dock == DockStyle.Bottom)
                {
                    y2 = Math.Min(y2, control.Top);
                }
            }

            if (x2 <= x1 || y2 <= y1)
            {
                return(new Rectangle());
            }

            Rectangle result = new Rectangle(x1, y1, x2 - x1, y2 - y1);

            return(wrapper.RectangleToScreen(result));
        }
Example #2
0
      /// <summary>
      /// GEt fill screen rectangle
      /// </summary>
      /// <param name="wrapper">wrapper</param>
      /// <returns></returns>
      public static Rectangle GetFillScreenRectangle(FormWrapper wrapper)
      {
         Rectangle clientArea  = wrapper.RectangleToClient(GetScreenClientRectangle(wrapper._host));

         int x1 = clientArea.Left;
         int x2 = clientArea.Right;
         int y1 = clientArea.Top;
         int y2 = clientArea.Bottom;

         for (int index = 0; index < wrapper.ControlsCount; index++)
         {
            Control control  = wrapper.GetControlAt(index);
            if (control.Dock == DockStyle.None || control.Visible == false)
            {
               continue;
            }

            if (control.Dock == DockStyle.Left)
            {
               x1 = Math.Max(x1, control.Right);
            }
            else if (control.Dock == DockStyle.Right)
            {
               x2 = Math.Min(x2, control.Left);
            }
            else if (control.Dock == DockStyle.Top)
            {
               y1 = Math.Max(y1, control.Bottom);
            }
            else if (control.Dock == DockStyle.Bottom)
            {
               y2 = Math.Min(y2, control.Top);
            }
         }

         if (x2 <= x1 || y2 <= y1)
         {
            return new Rectangle();
         }

         Rectangle result = new Rectangle(x1, y1, x2 - x1, y2 - y1);

         return wrapper.RectangleToScreen(result);
      }
Example #3
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(zAllowedDock 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, zAllowedDock.Left);
            bool dockRightGuiderVisible        = EnumUtility.Contains(allowedDockMode, zAllowedDock.Right);
            bool dockTopGuiderVisible          = EnumUtility.Contains(allowedDockMode, zAllowedDock.Top);
            bool dockBottomGuiderVisible       = EnumUtility.Contains(allowedDockMode, zAllowedDock.Bottom);
            bool dockFillGuiderShowFillPreview = EnumUtility.Contains(allowedDockMode, zAllowedDock.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;
        }