public void RefreshHotkeys(IList <Hotkey> newHotkeys)
        {
            var wasSuspended = hotkeyListener.Suspended;

            if (wasSuspended)
            {
                hotkeyListener.Resume();
            }

            hotkeyListener.RemoveAll();

            foreach (var hotkey in newHotkeys)
            {
                if (hotkey != null)
                {
                    AddHotkey(hotkey);
                }
            }
            hotkeyListener.Add(new Hotkey(System.Windows.Forms.Keys.Escape));

            if (wasSuspended)
            {
                hotkeyListener.Suspend();
            }
        }
Example #2
0
        public void SettingsChanges(IReadOnlyCollection <Setting> settings)
        {
            _dispatcher.Invoke(() => _hotkeyListener.RemoveAll());
            _hotkeys.Clear();

            foreach (var setting in settings)
            {
                if (string.IsNullOrWhiteSpace(setting.Value))
                {
                    continue;
                }

                if (HotKeyParser.TryConvert(setting.Value, out var hotkey, out var key))
                {
                    _hotkeys.Add(new HotKeySetup
                    {
                        Name   = setting.Name,
                        Value  = setting.Value,
                        HotKey = hotkey
                    });
                }
Example #3
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     hotkeyListener.RemoveAll();
 }