Exemplo 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);
        }
Exemplo n.º 2
0
        private int _counter            = -1;                                   // Joystick index counter.
        #endregion

        #region Methods.
        /// <summary>
        /// Handles the KeyDown event of the _keyboard control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="KeyboardEventArgs" /> instance containing the event data.</param>
        private void _keyboard_KeyDown(object sender, KeyboardEventArgs e)
        {
            switch (e.Key)
            {
            case KeyboardKeys.Escape:
                Close();                                                // Close
                break;

            case KeyboardKeys.F:
                _screen.UpdateSettings(!_screen.Settings.IsWindowed);
                break;

            case KeyboardKeys.Down:
                _radius -= 1.0f;
                if (_radius < 2.0f)
                {
                    _radius = 2.0f;
                }
                break;

            case KeyboardKeys.Up:
                _radius += 1.0f;
                if (_radius > 10.0f)
                {
                    _radius = 10.0f;
                }
                break;

            case KeyboardKeys.F1:
                _blendMode = BlendingMode.Modulate;
                break;

            case KeyboardKeys.F2:
                _blendMode = BlendingMode.Additive;
                break;

            case KeyboardKeys.F3:
                _blendMode = BlendingMode.None;
                break;

            case KeyboardKeys.C:
                // Fill the back up image with white.
                using (var imageLock = _backupImage.Lock(BufferLockFlags.Write))
                {
                    imageLock.Data.Fill(0xFF);
                }

                _backBuffer.CopySubResource(_backupImage,
                                            new Rectangle(0, 0, _backBuffer.Settings.Width, _backBuffer.Settings.Height));
                break;

            case KeyboardKeys.J:
                if (_input.JoystickDevices.Count != 0)
                {
                    // Disable if we go beyond the end of the list.
                    _counter++;
                    if ((_counter >= _input.JoystickDevices.Count) && (_joystick != null))
                    {
                        _joystick           = null;
                        _counter            = -1;
                        _messageSprite.Text = "Using mouse and keyboard.";
                        break;
                    }

                    // Move to the next joystick.
                    _joystick           = _joystickList[_counter];
                    _messageSprite.Text = "Using joystick " + _joystick.Name;
                }
                break;
            }
        }