Esempio n. 1
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Form.ResizeEnd" /> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.EventArgs" /> that contains the event data.</param>
        protected override void OnResizeEnd(EventArgs e)
        {
            base.OnResizeEnd(e);

            var currentImageSize = new Size(_backBuffer.Settings.Width, _backBuffer.Settings.Height);

            // Copy the render target texture to a temporary buffer and resize the main buffer.
            // The copy the temporary buffer back to the main buffer.
            _backupImage.CopySubResource(_backBuffer,
                                         new Rectangle(Point.Empty, currentImageSize));

            _backBuffer.Dispose();
            _backBuffer = _graphics.Output.CreateRenderTarget("BackBuffer", new GorgonRenderTarget2DSettings
            {
                Width  = ClientSize.Width,
                Height = ClientSize.Height,
                Format = BufferFormat.R8G8B8A8_UIntNormal
            });
            _backBuffer.Clear(Color.White);
            _backBuffer.CopySubResource(_backupImage,
                                        new Rectangle(0, 0, _backBuffer.Settings.Width, _backBuffer.Settings.Height));

            // Set the mouse range to the new size.
            _mouse.SetPositionRange(0, 0, ClientSize.Width, ClientSize.Height);
        }