public int AddNewControlHotkey(string key, ControlRoles role, out string displayedVal, string holdDownKey = "", float flowChangeValue = 0) { ControlHotkey ctrlHk = null; KeyAndModifiers fullKey = CreateAndValidateFullKey(key); displayedVal = ""; ctrlHk = new ControlHotkey(fullKey, role); switch (role) { case ControlRoles.Forward: case ControlRoles.Backward: ctrlHk.FlowChangeValue = flowChangeValue; displayedVal = flowChangeValue + " sec"; break; case ControlRoles.IncreaseVolume: case ControlRoles.DecreaseVolume: ctrlHk.FlowChangeValue = flowChangeValue; displayedVal = flowChangeValue + "%"; break; case ControlRoles.HoldDownKey: ctrlHk.HoldDownKey = keysTranslater.StringToKeyCode(holdDownKey); displayedVal = holdDownKey; break; case ControlRoles.IncreaseTempo: case ControlRoles.DecreaseTempo: case ControlRoles.IncreaseSpeed: case ControlRoles.DecreaseSpeed: ctrlHk.FlowChangeValue = flowChangeValue; displayedVal = flowChangeValue + "%"; break; case ControlRoles.IncreasePitch: case ControlRoles.DecreasePitch: ctrlHk.FlowChangeValue = flowChangeValue; displayedVal = "+" + (flowChangeValue / 10) + ((flowChangeValue / 10) >= 2 ? " semitones" : " semitone"); break; case ControlRoles.MasterHotkey: ctrlHk = null; if (MasterHotkey.Registered) { throw new MasterHotkeyUsedException(MasterHotkey.Key.FullKeyString); } MasterHotkey.Key = fullKey; CheckHotkeyResult(MasterHotkey.Register(mainFrm), key); return(MasterHotkey.Id); } CheckHotkeyResult(ctrlHk.Register(mainFrm), key); hotkeysList.Add(ctrlHk); return(ctrlHk.Id); }
public void ClearHotkeysList() { foreach (IHotkey hk in hotkeysList) { hk.Unregister(); } hotkeysList.Clear(); if (MasterHotkey.Registered) { MasterHotkey.Unregister(); } }
public void RemoveHotkey(int hotkeyId) { if (hotkeyId == MasterHotkey.Id) { MasterHotkey.Unregister(); } else { IHotkey hk = FindHotkeyById(hotkeyId); hk.Unregister(); hotkeysList.Remove(hk); } }