private void UpdateHotkeyActivator(GenericHotkeyProxy hotkeyProxy, HotkeyType newHotkeyType, object newActivator, string text) { this.TxtSingleKey.Text = text; // This should be called before changing the hotkey type; otherwise, it will return the Key/MouseAction // used by the previous *keyboard/mouse hotkey* instead of the activator used by the previous *generic hotkey*. // This doesn't make any difference if we are not changing hotkey type. object previousActivator = hotkeyProxy.GetActivator(); HotkeyType previousType = hotkeyProxy.Type; hotkeyProxy.Type = newHotkeyType; hotkeyProxy.SetActivator(newActivator); if (!previousActivator.Equals(hotkeyProxy.GetActivator())) { // Check every hotkey's validity again in case one of them has been set to use // the same activator this hotkey was previously using. this.VerifyHotkeysValidityAgainst(hotkeyProxy, null, previousType, previousActivator); } }
private void VerifyHotkeysValidityAgainst(GenericHotkeyProxy hotkeyProxy, ModifierKeys?previousModifiers, HotkeyType?previousType, object previousActivator) { var hotkeys = this.settingsViewModel.Hotkeys; foreach (var hp in hotkeys) { if (hp == hotkeyProxy) { continue; } if (hp.IsAlreadyInUseBy(previousModifiers ?? hotkeyProxy.Hotkey.Modifiers, previousType ?? hotkeyProxy.Type, previousActivator ?? hotkeyProxy.GetActivator())) { if (!this.settingsViewModel.CheckIfHotkeyIsAlreadyInUse(hp)) { hp.Hotkey.SetIsValid(true, null); } } } }