Register failed hotkeys on hotkey settings form startup

This commit is contained in:
Jaex 2023-06-27 02:25:14 +03:00
parent 82449c643f
commit c4dde0c3a0
2 changed files with 11 additions and 11 deletions

View file

@ -64,6 +64,7 @@ public void PrepareHotkeys(HotkeyManager hotkeyManager)
{
manager = hotkeyManager;
manager.HotkeysToggledTrigger += HandleHotkeysToggle;
manager.RegisterFailedHotkeys();
AddControls();
}
@ -113,21 +114,12 @@ private void UpdateHotkeyStatus()
}
}
private void RegisterFailedHotkeys()
{
foreach (HotkeySettings hotkeySettings in manager.Hotkeys.Where(x => x.HotkeyInfo.Status == HotkeyStatus.Failed))
{
manager.RegisterHotkey(hotkeySettings);
}
UpdateHotkeyStatus();
}
private void control_HotkeyChanged(object sender, EventArgs e)
{
HotkeySelectionControl control = (HotkeySelectionControl)sender;
manager.RegisterHotkey(control.HotkeySettings);
RegisterFailedHotkeys();
manager.RegisterFailedHotkeys();
UpdateHotkeyStatus();
}
private HotkeySelectionControl AddHotkeySelectionControl(HotkeySettings hotkeySettings)

View file

@ -127,6 +127,14 @@ public void RegisterAllHotkeys()
}
}
public void RegisterFailedHotkeys()
{
foreach (HotkeySettings hotkeySetting in Hotkeys.Where(x => x.HotkeyInfo.Status == HotkeyStatus.Failed))
{
RegisterHotkey(hotkeySetting);
}
}
public void UnregisterHotkey(HotkeySettings hotkeySetting, bool removeFromList = true)
{
if (hotkeySetting.HotkeyInfo.Status == HotkeyStatus.Registered)