Example #1
0
        private void EditHotkey(object sender, KeyEventArgs e)
        {
            if (!_keyRecording)
            {
                _settings.KeyCombo = "";
                _modifierKey       = 0;
                _virtualKey        = 0;
                _keyRecording      = true;
            }

            Debug.WriteLine($"Key state: {e.Key}");

            if (e.Key == Key.LeftShift || e.Key == Key.RightShift)
            {
                _modifierKey        = _modifierKey | ModifierKeys.Shift;
                _settings.KeyCombo += "Shift ";
            }

            else if (e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl)
            {
                _modifierKey        = _modifierKey | ModifierKeys.Control;
                _settings.KeyCombo += "Ctrl ";
            }

            else if (e.Key == Key.LeftAlt || e.Key == Key.RightAlt)
            {
                _modifierKey        = _modifierKey | ModifierKeys.Alt;
                _settings.KeyCombo += "Alt ";
            }

            else
            {
                // key recording complete
                _virtualKey         = e.Key;
                _settings.KeyCombo += e.Key;
                _keyRecording       = false;
                // create event args and fire update event
                var keyArgs = new QueryHotkeyUpdatedEventArgs
                {
                    ModKeys = _modifierKey,
                    VirtKey = _virtualKey
                };
                Instance.UpdateQueryHotkey(keyArgs);
            }

            Debug.WriteLine($"Modkeys is now {(uint)_modifierKey}; Virtkey is now {(uint)_virtualKey}");
        }
Example #2
0
 /// <summary>
 /// Overwrites the current query hotkey.
 /// </summary>
 /// <param name="modKeys">New modifier key combo.</param>
 /// <param name="virtKey">New virtual key.</param>
 public void UpdateQueryHotkey(object sender, QueryHotkeyUpdatedEventArgs e)
 {
     _hotkey.RegisterNewHotkey("QueryKey", e.ModKeys, e.VirtKey, OnHotKeyHandler);
 }
Example #3
0
 public void UpdateQueryHotkey(QueryHotkeyUpdatedEventArgs e)
 {
     OnQueryHotkeyUpdated(e);
 }
Example #4
0
 protected virtual void OnQueryHotkeyUpdated(QueryHotkeyUpdatedEventArgs e)
 {
     QueryHotkeyUpdated?.Invoke(this, e);
 }