Exemplo n.º 1
0
        /// <summary>
        /// Determines whether the event arguments match the specified key combination.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="modifierKeys">The modifier keys.</param>
        /// <returns>True if the event arguments match the specified key combination, otherwise false.</returns>
        public bool Match(Key key, ModifierKeys modifierKeys = ModifierKeys.None)
        {
            if (this.Key == key)
            {
                if (key == Keyboard.LeftControl || key == Keyboard.RightControl)
                {
                    return (this.ModifierKeys | ModifierKeys.Control) == (modifierKeys | ModifierKeys.Control);
                }

                if (key == Keyboard.LeftAlt || key == Keyboard.RightAlt)
                {
                    return (this.ModifierKeys | ModifierKeys.Alt) == (modifierKeys | ModifierKeys.Alt);
                }

                if (key == Keyboard.LeftShift || key == Keyboard.RightShift)
                {
                    return (this.ModifierKeys | ModifierKeys.Shift) == (modifierKeys | ModifierKeys.Shift);
                }

                if (key == Keyboard.LeftWindows || key == Keyboard.RightWindows)
                {
                    return (this.ModifierKeys | ModifierKeys.Windows) == (modifierKeys | ModifierKeys.Windows);
                }

                return this.ModifierKeys == modifierKeys;
            }

            return false;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Called when a key is pressed or released.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="modifierKeys">The modifier keys.</param>
 public override void OnKey(Key key)
 {
     if (Keyboard.Esc)
     {
         this.menu.Visibility = this.menu.Visibility == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Called when a key is pressed or released.
        /// </summary>
        /// <param name="key">The key.</param>
        public override void OnKey(Key key)
        {
            if (Keyboard.Esc)
            {
                this.Shutdown();
            }

            if (Keyboard.Match(Keyboard.Enter, ModifierKeys.Alt))
            {
                if (Game.Settings.DisplayMode == null)
                {
                    Game.Settings.DisplayMode = DisplayMode.Select("default");
                }
                else
                {
                    Game.Settings.DisplayMode = null;
                }
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Called when a key is pressed or released.
 /// </summary>
 /// <param name="key">The key.</param>
 public virtual void OnKey(Key key) { }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="KeyEventArgs" /> class.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="modifierKeys">The modifier keys.</param>
 public KeyEventArgs(Key key, ModifierKeys modifierKeys)
 {
     this.Key = key;
     this.ModifierKeys = modifierKeys;
 }