Esempio n. 1
0
        public static Point GetValidLocationForDropDown(
            RadDirection popupDirection,
            Rectangle screenRect,
            Size popupSize,
            Rectangle ownerRect,
            int ownerOffset,
            ref bool corected)
        {
            Point        point      = RadPopupHelper.CalcLocation(popupDirection, popupSize, ownerRect, ownerOffset);
            Point        location   = point;
            RadDirection correction = popupDirection;
            Rectangle    rectangle  = new Rectangle(location, popupSize);

            if (RadPopupHelper.GetCorrectingDirection(rectangle, screenRect, ref correction))
            {
                location  = RadPopupHelper.CalcLocation(correction, popupSize, ownerRect, ownerOffset);
                rectangle = new Rectangle(location, popupSize);
                if (RadPopupHelper.GetCorrectingDirection(rectangle, screenRect, ref correction))
                {
                    location = point;
                }
                corected = true;
            }
            rectangle.Location = location;
            return(RadPopupHelper.EnsureBoundsInScreen(rectangle, screenRect).Location);
        }
Esempio n. 2
0
        public static Point GetValidLocationForContextMenu(
            RadDirection popupDirection,
            Point location,
            Size popupSize,
            ref bool corected)
        {
            Rectangle screenRect = RadPopupHelper.GetScreenRect(location);
            Rectangle rectangle  = new Rectangle(location, popupSize);
            Point     point      = location;

            switch (popupDirection)
            {
            case RadDirection.Left:
                location = new Point(rectangle.Left - popupSize.Width, rectangle.Top);
                break;

            case RadDirection.Up:
                location = new Point(rectangle.Left, rectangle.Top - popupSize.Height);
                break;
            }
            if (RadPopupHelper.GetCorrectingDirection(rectangle, screenRect, ref popupDirection))
            {
                switch (popupDirection)
                {
                case RadDirection.Left:
                    location = new Point(rectangle.Left - popupSize.Width, rectangle.Top);
                    break;

                case RadDirection.Right:
                    location = new Point(rectangle.Right, rectangle.Top);
                    break;

                case RadDirection.Up:
                    location = new Point(rectangle.Left, rectangle.Top - popupSize.Height);
                    break;

                case RadDirection.Down:
                    location = new Point(rectangle.Left, rectangle.Bottom);
                    break;
                }
                rectangle = new Rectangle(location, popupSize);
                if (RadPopupHelper.GetCorrectingDirection(rectangle, screenRect, ref popupDirection))
                {
                    location = point;
                }
                corected = true;
            }
            rectangle.Location = location;
            rectangle          = RadPopupHelper.EnsureBoundsInScreen(rectangle, screenRect);
            return(rectangle.Location);
        }