Esempio n. 1
0
 void HandleKeyboardHookKeyPressed(object sender, KeyPressedEventArgs e)
 {
     if (KeyStroke.TryConvert(e, out var keyStroke))
     {
         TryRequestShortcut(keyStroke);
     }
 }
        void HandlePreviewKeyDown(object sender, KeyEventArgs e)
        {
            e.Handled = true;
            var keyStroke = new KeyStroke(
                Keyboard.Modifiers,
                GetKeyIgnoringModifiers(Keyboard.Modifiers, e.Key)
                );

            ViewModel.Builder.SetKeyStroke(keyStroke);
        }
Esempio n. 3
0
        /// <summary>
        /// Registers a hot key in the system.
        /// </summary>
        /// <param name="modifier">The modifiers that are associated with the hot key.</param>
        /// <param name="key">The key itself that is associated with the hot key.</param>
        public void RegisterHotKey(KeyStroke keyStroke)
        {
            // increment the counter.
            _currentId++;

            // register the hot key.
            if (!NativeMethods.RegisterHotKey(_window.Handle, _currentId, (uint)keyStroke.ModifierKeys, (uint)keyStroke.GetWinFormsKey()))
            {
                throw new InvalidOperationException("Couldn’t register the hot key.");
            }

            _keyStrokeMap[keyStroke] = _currentId;
        }
Esempio n. 4
0
        private void HandlePreviewKeyDown(object sender, KeyEventArgs e)
        {
            var keyStroke = new KeyStroke(
                Keyboard.Modifiers,
                e.Key
                );

            if (_appService.ShortcutService.TryRequestShortcut(keyStroke))
            {
                e.Handled = true;
            }
            else if (e.Key == Key.Tab)
            {
                e.Handled = true;
            }
        }
 public bool TryRequestShortcut(KeyStroke keyStroke) => false;
 public bool TryAddShortcut(KeyStroke keyStroke, AppAction appAction) => false;
 public void RemoveShortcut(KeyStroke keyStroke)
 {
 }