Ejemplo n.º 1
0
        /// <summary>
        /// Ensures that the window stays within width and height of the display.
        /// </summary>
        private static void EnsureBounds(int desiredX, int desiredY)
        {
            var screen = SystemParameters.WorkArea;
            int x      = desiredX + (desiredX < screen.Width / 2 ? WINDOW_PADDING : -WINDOW_WIDTH - WINDOW_PADDING);
            int y      = desiredY + (desiredY < screen.Height / 2 ? WINDOW_PADDING : -WINDOW_HEIGHT - WINDOW_PADDING);

            _overlayWindow.SetWindowPosition(x, y);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Ensures that the window stays within width and height of the display.
        /// </summary>
        private static void EnsureBounds(int desiredX, int desiredY, float scale)
        {
            var screenRect = Screen.FromPoint(Cursor.Position).Bounds;
            var xMidScaled = (screenRect.X + (screenRect.Width / 2)) * scale;
            var yMidScaled = (screenRect.Y + (screenRect.Height / 2)) * scale;

            var positionX = desiredX + (desiredX < xMidScaled ? WINDOW_PADDING : -WINDOW_WIDTH - WINDOW_PADDING);
            var positionY = desiredY + (desiredY < yMidScaled ? WINDOW_PADDING : -WINDOW_HEIGHT - WINDOW_PADDING);

            _overlayWindow.SetWindowPosition(positionX, positionY);
        }
Ejemplo n.º 3
0
        public static void SetPosition(int x, int y)
        {
            if (_overlayWindow == null)
            {
                Initialize();
            }

            // Ensure the window stays inside the screen but still appears on the mouse.
            var screen    = SystemParameters.WorkArea;
            var positionX = x + (x < screen.Width / 2 ? 0 : -WINDOW_WIDTH);
            var positionY = y + (y < screen.Height / 2 ? 0 : -WINDOW_HEIGHT);

            _overlayWindow.SetWindowPosition(positionX, positionY);
        }