예제 #1
0
 /// <summary>
 /// Call when any key is pressed.
 /// </summary>
 /// <param name="key">A ConsoleKey value.</param>
 /// <returns></returns>
 public void NotifyKeyPressed(int key)
 {
     try
     {
         if (HandlePossibleKeybind(key))
         {
             return;
         }
         TriggerHotkeys(key);
     }
     catch (Exception ex)
     {
         Logger.Debug(ex, "Handling key " + ConsoleKeyHelper.GetKeyName(key));
     }
 }
예제 #2
0
 /// <summary>
 /// Call when any key is pressed. Returns true if the key was consumed by a keybind event. If false, the key press may be used to trigger hotkeys.
 /// </summary>
 /// <param name="key">The key code.</param>
 /// <returns></returns>
 private bool HandlePossibleKeybind(int key)
 {
     if (GetCurrentBindState() == null)
     {
         return(false);
     }
     lock (GetLock())
     {
         BindState state = GetCurrentBindState();
         if (state == null)
         {
             return(false);
         }
         Logger.Info("[" + _bindState.bindId + "] Hotkey Bind - SET KEY " + ConsoleKeyHelper.GetKeyName(key));
         _bindState = null;
         return(ServiceWrapper.config.SetHotkeyKey(state.hotkeyId, key) != null);
     }
 }