/// <summary> /// Handles the KeyDown event of the _mainForm control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="KeyEventArgs" /> instance containing the event data.</param> /// <exception cref="System.NotSupportedException"></exception> static void _mainForm_KeyDown(object sender, KeyEventArgs e) { if ((e.Alt) && (e.KeyCode == Keys.Enter)) { _swap.UpdateSettings(!_swap.Settings.IsWindowed); } }
/// <summary> /// Handles the KeyDown event of the _form control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.KeyEventArgs"/> instance containing the event data.</param> private static void _form_KeyDown(object sender, KeyEventArgs e) { int ballIncrement = 1; switch (e.KeyCode) { case Keys.Pause: _paused = !_paused; break; case Keys.F1: _showHelp = !_showHelp; break; case Keys.Up: if ((e.Control) && (e.Shift)) { ballIncrement = 1000; } else { if (e.Control) { ballIncrement = 100; } if (e.Shift) { ballIncrement = 10; } } GenerateBalls(ballIncrement); break; case Keys.Down: if ((e.Control) && (e.Shift)) { ballIncrement = 1000; } else { if (e.Control) { ballIncrement = 100; } if (e.Shift) { ballIncrement = 10; } } GenerateBalls(-ballIncrement); break; case Keys.Enter: if (e.Alt) { _mainScreen.UpdateSettings(!_mainScreen.Settings.IsWindowed); } break; case Keys.OemMinus: _2D.Effects.GaussianBlur.BlurAmount += 0.25f; if (_2D.Effects.GaussianBlur.BlurAmount > 10) { _2D.Effects.GaussianBlur.BlurAmount = 10; } break; case Keys.Oemplus: _2D.Effects.GaussianBlur.BlurAmount -= 0.25f; if (_2D.Effects.GaussianBlur.BlurAmount < 2) { _2D.Effects.GaussianBlur.BlurAmount = 2; } break; } }
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; } }