/// <summary> /// Handles the KeyUp 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> private static void MainForm_KeyUp(object sender, KeyEventArgs e) { if ((e.KeyCode != Keys.Enter) || (!e.Alt) || (_swap == null)) { return; } if (!_swap.IsWindowed) { _swap.ExitFullScreen(); return; } IGorgonVideoOutputInfo output = _graphics.VideoAdapter.Outputs[GorgonApplication.MainForm.Handle]; if (output == null) { return; } // Find an appropriate video mode. var searchMode = new GorgonVideoMode(GorgonApplication.MainForm.ClientSize.Width, GorgonApplication.MainForm.ClientSize.Height, BufferFormat.R8G8B8A8_UNorm); output.VideoModes.FindNearestVideoMode(output, in searchMode, out GorgonVideoMode nearestMode); // To enter full screen borderless window mode, call EnterFullScreen with no parameters. _swap.EnterFullScreen(in nearestMode, output); }
/// <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="NotSupportedException"></exception> private static void _mainForm_KeyDown(object sender, KeyEventArgs e) { if ((!e.Alt) || (e.KeyCode != Keys.Enter)) { return; } if (!_swap.IsWindowed) { _swap.ExitFullScreen(); } else { // Get the output for the main window. var currentScreen = Screen.FromControl(_mainForm); IGorgonVideoOutputInfo output = _graphics.VideoAdapter.Outputs[currentScreen.DeviceName]; _swap.EnterFullScreen(in _selectedVideoMode, output); } }
/// <summary> /// Handles the <see cref="E:KeyDown" /> event. /// </summary> /// <param name="e">The <see cref="KeyEventArgs" /> instance containing the event data.</param> protected override void OnKeyUp(KeyEventArgs e) { switch (e.KeyCode) { case Keys.Escape: Close(); // Close break; case Keys.F: if (_screen.IsWindowed) { _screen.EnterFullScreen(); } else { _screen.ExitFullScreen(); } break; case Keys.Down: _radius -= 1.0f; if (_radius < 2.0f) { _radius = 2.0f; } break; case Keys.Up: _radius += 1.0f; if (_radius > 50.0f) { _radius = 50.0f; } break; case Keys.F1: _currentBlend = _drawModulatedBlend; break; case Keys.F2: _currentBlend = _drawAdditiveBlend; break; case Keys.F3: _currentBlend = _drawNoBlend; break; case Keys.C: // Fill the back up image with white _backBuffer.Clear(GorgonColor.White); _backBuffer.Texture.CopyTo(_backupImage); break; case Keys.J: // Disable if we go beyond the end of the list. _counter++; if (_counter == -1) { // Clip the mouse cursor to our client area. Cursor.Clip = _mouse.PositionConstraint = RectangleToScreen(ClientRectangle); // Set the position to the current mouse position. _mouse.Position = Cursor.Position; _input.RegisterDevice(_mouse); _useWinFormsInput = false; _messageSprite.Text = "Using mouse and keyboard (Raw Input)"; break; } if ((_joystickList.Count == 0) || ((_counter >= _joystickList.Count) && (_joystick != null))) { if (!_useWinFormsInput) { Cursor.Clip = Rectangle.Empty; _input.UnregisterDevice(_mouse); } _useWinFormsInput = true; _joystick = null; _counter = -2; _messageSprite.Text = "Using mouse and keyboard (Windows Forms)."; break; } // If we previously had raw input on, turn it off. if (!_useWinFormsInput) { Cursor.Clip = Rectangle.Empty; _input.UnregisterDevice(_mouse); _useWinFormsInput = true; } // Move to the next joystick. _joystick = _joystickList[_counter]; _messageSprite.Text = "Using joystick " + _joystick.Info.Description; break; } }
/// <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="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) { if (_mainScreen.IsWindowed) { IGorgonVideoOutputInfo output = _graphics.VideoAdapter.Outputs[_window.Handle]; if (output == null) { _mainScreen.EnterFullScreen(); } else { var mode = new GorgonVideoMode(_window.ClientSize.Width, _window.ClientSize.Height, BufferFormat.R8G8B8A8_UNorm); _mainScreen.EnterFullScreen(in mode, output); } } else { _mainScreen.ExitFullScreen(); } } break; case Keys.OemMinus: _blur.BlurRadius--; if (_blur.BlurRadius < 0) { _blur.BlurRadius = 0; } break; case Keys.Oemplus: _blur.BlurRadius++; if (_blur.BlurRadius > _blur.MaximumBlurRadius) { _blur.BlurRadius = _blur.MaximumBlurRadius; } break; } }