Example #1
0
        private void RefreshHotkeys()
        {
            // Unregister all hotkeys.
            foreach (var hotkey in _hotkeys)
            {
                hotkey.Dispose();
            }
            _hotkeys.Clear();

            // Remove any hotkeys for profiles that no longer exist (but keep hotkeys for system commands).
            if (SettingsFiles.ApplicationSettings.Hotkeys.RemoveAll(x => !SystemCommands.IsSystemCommand(x.Id) && !_profiles.ContainsKey(x.Id)) != 0)
            {
                SettingsFiles.SaveApplicationSettings();
            }

            // Register hotkeys.
            foreach (var hotkeySetting in SettingsFiles.ApplicationSettings.Hotkeys)
            {
                var id = hotkeySetting.Id;
                try
                {
                    _hotkeys.Add(new WinFormsHotkey(hotkeySetting.Hotkey, true, () => ExecuteSystemCommandOrLoadProfile(hotkeySetting.Id)));
                }
                catch (Exception ex)
                {
                    BalloonTip("Could not bind hotkey " + WinFormsHotkey.HotkeyString(hotkeySetting.Hotkey) + " to " + SystemCommands.GetTitle(id), ex.Message, ToolTipIcon.Warning);
                }
            }
        }
Example #2
0
 private void DeleteProfile(string name)
 {
     ExecuteUiAction(() =>
     {
         SettingsFiles.ApplicationSettings.SetHotkey(name, Keys.None);
         SettingsFiles.SaveApplicationSettings();
         ProfileFiles.DeleteProfile(name);
     }, "Could not delete display profile " + name);
 }
Example #3
0
 private void SetHotkey(string id)
 {
     ExecuteUiAction(() =>
     {
         var result = SetHotkeyDialog.ExecuteDialog(SystemCommands.GetTitle(id), SettingsFiles.ApplicationSettings.FindHotkey(id));
         if (result == null)
         {
             return;
         }
         SettingsFiles.ApplicationSettings.SetHotkey(id, result.Value);
         SettingsFiles.SaveApplicationSettings();
     }, "Could not set hotkey for " + SystemCommands.GetTitle(id));
 }