Пример #1
0
        /// <summary>
        /// Handles a WM_MOUSEMOVE message for the mouse.
        /// </summary>
        /// <param name="window">The <see cref="Certus.Core.GameWindow"/> which represents the window on which the game is displayed.</param>
        /// <param name="x">The new x-coordinate of the mouse, relative to the upper-left corner of the window.</param>
        /// <param name="y">The new y-coordinate of the mouse, relative to the upper-left corner of the window.</param>
        internal void OnMouseMove(GameWindow window, int x, int y)
        {
            // x = x;
            y = window.Height - y;

            this.m_NewX = x;
            this.m_NewY = y;
        }
Пример #2
0
            /// <summary>
            /// Initializes a new instance of the <see cref="Certus.Core.GameWindow.GameForm"/> class.
            /// </summary>
            /// <param name="window">The <see cref="Certus.Core.GameWindow"/> on which graphics and text is rendered.</param>
            public GameForm(GameWindow window)
            {
                this.m_Window = window;

                this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); // reduces flicker
                this.SetStyle(ControlStyles.DoubleBuffer, true); // reduces flicker
                this.SetStyle(ControlStyles.UserPaint, true); // only Paint event drawing, no OS drawing

                this.Paint += (sender, arguments) => this.m_Window.m_Renderer.Draw(arguments.Graphics);
                this.ClientSizeChanged += (sender, arguments) => this.m_Window.m_Renderer.SetOffset(this.m_Window.Width, this.m_Window.Height);
            }
Пример #3
0
        /// <summary>
        /// Prepares the window.
        /// </summary>
        /// <param name="width">The width in pixels of the window, excluding borders.</param>
        /// <param name="height">The height in pixels of the window, excluding borders.</param>
        /// <exception cref="System.InvalidOperationException">
        /// Thrown when the window has already been prepared.
        /// </exception>
        /// <exception cref="System.ArgumentException">
        /// Thrown when 'width' is equal to or smaller than 0.
        ///  - OR - 
        /// Thrown when 'height' is equal to or smaller than 0.
        /// </exception>
        protected void PrepareWindow(int width, int height)
        {
            if (this.m_Window != null)
                new InvalidOperationException("The window has already been prepared.");
            if (width <= 0)
                new ArgumentException("'" + nameof(width) + "' cannot be equal to or smaller than 0.", nameof(width));
            if (height <= 0)
                new ArgumentException("'" + nameof(height) + "' cannot be equal to or smaller than 0.", nameof(height));

            this.m_Window = new GameWindow(width, height);
            this.m_Window.Form.FormClosed += (sender, arguments) => this.Exit();
        }