Пример #1
0
        /// <summary>
        /// Handles the KeyUp event of the _keyboard control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GorgonKeyboardEventArgs" /> instance containing the event data.</param>
        private void _keyboard_KeyUp(object sender, GorgonKeyboardEventArgs e)
        {
            // If we press "P", then switch between polling and events.
            if (e.Key == Keys.P)
            {
                _mouse.RelativePositionOffset = Point.Empty;
                _usePolling = !_usePolling;
                if (_usePolling)
                {
                    // Turn off mouse events when polling.
                    _mouse.MouseMove       -= _mouse_Move;
                    _mouse.MouseButtonDown -= _mouse_ButtonDown;
                    _mouse.MouseButtonUp   -= _mouse_ButtonUp;
                }
                else
                {
                    // Turn on mouse events when not polling.
                    _mouse.MouseMove       += _mouse_Move;
                    _mouse.MouseButtonDown += _mouse_ButtonDown;
                    _mouse.MouseButtonUp   += _mouse_ButtonUp;
                }
            }

            UpdateKeyboard(Keys.None, e.ModifierKeys);
        }
Пример #2
0
        /// <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="GorgonKeyboardEventArgs" /> instance containing the event data.</param>
        private void _keyboard_KeyDown(object sender, GorgonKeyboardEventArgs e)
        {
            // Exit the application.
            if (e.Key == Keys.Escape)
            {
                Close();
                return;
            }

            UpdateKeyboard(e.Key, e.ModifierKeys);
        }
Пример #3
0
        /// <summary>Handles the KeyUp event of the Keyboard control.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="GorgonKeyboardEventArgs"/> instance containing the event data.</param>
        private static void Keyboard_KeyUp(object sender, GorgonKeyboardEventArgs e)
        {
            switch (e.Key)
            {
            case Keys.C:
                if (_ship.LayerController != null)
                {
                    LayerCamera controller = _ship.LayerController;
                    _ship.LayerController     = null;
                    _shipDeux.LayerController = controller;
                }
                else
                {
                    LayerCamera controller = _shipDeux.LayerController;
                    _shipDeux.LayerController = null;
                    _ship.LayerController     = controller;
                }
                break;

            case Keys.F1:
                _showInstructions = !_showInstructions;
                break;
            }
        }