예제 #1
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));
 }
예제 #2
0
 /// <summary>
 /// Executes the dialog for a specific profile name and existing hotkey. Returns <c>null</c> if the user cancelled, <c>Keys.None</c> to remove a hotkey; otherwise, returns the new hotkey.
 /// </summary>
 /// <param name="profileName">The name of the profile.</param>
 /// <param name="existingHotkey">The existing hotkey for that profile.</param>
 public static Keys?ExecuteDialog(string profileName, Keys existingHotkey)
 {
     using (var dialog = new SetHotkeyDialog())
     {
         dialog.Text              += profileName;
         dialog.originalKeys       = dialog.keys = existingHotkey;
         dialog.hotkeyTextBox.Text = WinFormsHotkey.HotkeyString(existingHotkey);
         dialog.EnableDisableButtons();
         var result = dialog.ShowDialog();
         if (result != DialogResult.OK)
         {
             return(null);
         }
         return(dialog.keys);
     }
 }