private void TryGetCommand(ICollection <Keys> pressedKeys) { if (IsLoading) { return; } // a shortcut begins with at least two keys pressed simultaneously if ((_keyCombinations.Count == 0 && pressedKeys.Count <= 1) || (pressedKeys.Where(x => !(ShortcutToCommandConverter.IsAltKey(x) || ShortcutToCommandConverter.IsControlKey(x) || ShortcutToCommandConverter.IsShiftKey(x))).Count() == 0)) { return; } _keyCombinations.Add(pressedKeys.ToList()); var commands = new List <Command>(); if (_shortcutToCommandConverter.TryGetCommand(_keyCombinations, commands)) { _keyCombinations.Clear(); UpdateShortcut(commands); } else { _logger.Log("Cannot find a shortcut with these bindings: " + ShortcutToCommandConverter.ConvertToKeyBinding(_keyCombinations)); } }
public CodeNinjaSpyViewModel() { _shortcutToCommandConverter = new ShortcutToCommandConverter(_logger); _shortcutToCommandConverter.CommandFetchingStatusUpdated += (s, e) => { Status = e.Status; StatusText = e.StatusText; IsLoading = e.IsLoading; }; _shortcutToCommandConverter.CommandWithoutShortcut += (s, e) => { UpdateShortcut(new List<Command> { e.Command }); }; _keyInterceptor = new InterceptKeys(); _keyInterceptor.KeyIntercepted += (sender, eArgs) => TryGetCommand(eArgs.PressedKeys); _debugOpacity = 0.01; }
public CodeNinjaSpyViewModel() { _shortcutToCommandConverter = new ShortcutToCommandConverter(_logger); _shortcutToCommandConverter.CommandFetchingStatusUpdated += (s, e) => { Status = e.Status; StatusText = e.StatusText; IsLoading = e.IsLoading; }; _shortcutToCommandConverter.CommandWithoutShortcut += (s, e) => { UpdateShortcut(new List <Command> { e.Command }); }; _keyInterceptor = new InterceptKeys(); _keyInterceptor.KeyIntercepted += (sender, eArgs) => TryGetCommand(eArgs.PressedKeys); _debugOpacity = 0.01; }