private bool KeyPressedMatchShortcut(Shortcut <VirtualKeys> shortcut) { if (KeyPressed.Contains(shortcut.Key.Value)) { if (shortcut.BaseModifiers.Length + 1 == KeyPressed.Count) { bool allModifiers = true; foreach (var baseModifier in shortcut.BaseModifiers) { switch (baseModifier) { case KeyModifier.Ctrl: if (!KeyPressed.Contains(VirtualKeys.Control)) { allModifiers = false; } break; case KeyModifier.Shift: if (!KeyPressed.Contains(VirtualKeys.Shift)) { allModifiers = false; } break; case KeyModifier.Alt: if (!KeyPressed.Contains(VirtualKeys.Menu)) { allModifiers = false; } break; case KeyModifier.Win: if (!KeyPressed.Contains(VirtualKeys.LeftWindows)) { allModifiers = false; } break; default: allModifiers = false; break; } } if (allModifiers) { return(true); } } } return(false); }
private bool RemoveKey(VirtualKeys virtualKey) { bool result = false; if (!KeyPressed.Contains(virtualKey)) { AddKey(virtualKey); } KeyPressed.Remove(virtualKey); if (KeyUsed.Contains(virtualKey)) { KeyUsed.Remove(virtualKey); result = true; } return(result); }