public IRegisteredShortcut RegisterShortcut(IShortcut iShortcut, IOperation operation) { if (iShortcut is Shortcut <E> shortcut) { try { int id = NextIdToRegister; NextIdToRegister += 1; var result = RegisterHotKey(shortcut, id); this.LogLine("RegisterHotKey/{3}({0}, {1}, {2}) => {4}", id, operation.Name, shortcut.Name, GetType().Name, result.ToRepr()); if (result) { var registeredShortcut = new RegisteredShortcut <E>(shortcut, operation, id); RegisteredShortcuts[id] = registeredShortcut; return(registeredShortcut); } } catch { } } return(null); }
protected void ExecuteRegisteredShortcut(RegisteredShortcut <E> registeredShortcut) { this.LogLine(" Executing action [{0}] due to shortcut [{1}] registered as [{2}]", registeredShortcut.Operation.Name, registeredShortcut.Shortcut.Name, registeredShortcut.Id); registeredShortcut.Operation.Action(); }