Ejemplo n.º 1
0
        /// <summary>
        /// Called upon the resizing of the game window.
        /// </summary>
        private static void GameWindowResizeDelegate()
        {
            // Retrieve window size of target window.
            Point windowSize = WindowProperties.GetClientAreaSize2(GameProcess.Process.MainWindowHandle);

            // Resize and/or move elements or needed.
            // Implementation of this is up to you.

            // Well, except this, because the old factory for _textFormat will become outdated and will throw a nice fat exception.
            _initialized = false;
        }
        /// <summary>
        /// Sets the overlay window location to overlap the window of the game instance.
        /// Both moves the window to the game location and sets appropriate height and width for the window.
        /// </summary>
        public void AdjustOverlayToGameWindow()
        {
            // Get game client edges.
            Structures.WinapiRectangle gameClientSize = WindowProperties.GetClientRectangle(GameWindowHandle);

            // Set overlay edges to the edges of the client area.
            Left = gameClientSize.LeftBorder;
            Top  = gameClientSize.TopBorder;

            // Set width and height.
            Width  = gameClientSize.RightBorder - gameClientSize.LeftBorder;
            Height = gameClientSize.BottomBorder - gameClientSize.TopBorder;

            // Call resize delegate.
            if (lastWindowSize != WindowProperties.GetClientAreaSize2(GameWindowHandle))
            {
                GameWindowResizeDelegate?.Invoke();
            }

            lastWindowSize = WindowProperties.GetClientAreaSize2(GameWindowHandle);
        }