private void HotKeyPressed(short id, IntPtr currentWindowHandle) { HotKeyFunction functionCalled = Runtime.Instance.Settings.HotKeys.GetFunction(id); Runtime.Instance.WriteDebug(nameof(HotKeyPressed), nameof(functionCalled), functionCalled, "HotKeys"); switch (functionCalled) { case HotKeyFunction.HideCurrentWindow: if (!currentWindowHandle.Equals(IntPtr.Zero)) { WindowInfo.Find(currentWindowHandle).Hide(); } break; case HotKeyFunction.UnhideAllWindows: this.UnhideAllWindows(this, new EventArgs()); break; case HotKeyFunction.ToggleLastWindow: WindowInfo.Last?.ToggleHidden(); break; case HotKeyFunction.UnhideLastWindow: Runtime.Instance.WindowManager.GetLastWindow()?.Show(); break; default: break; } }
private HotKey(HotKeyFunction function, Keys key, HotModifierKeys modifiers) : this() { this.Function = function; this.Key = key; this.ModifierKeys = modifiers; }
internal static HotKey AddOrFind(HotKeyFunction hotKeyFunction) { HotKey hkey = Runtime.Instance.Settings.HotKeys.ToList().Find(x => x.Function == hotKeyFunction); if (hkey == null) { Runtime.Instance.Settings.HotKeys.Add(hkey = new HotKey(hotKeyFunction)); } return hkey; }
internal static HotKey AddOrFind(HotKeyFunction hotKeyFunction) { HotKey hkey = Runtime.Instance.Settings.HotKeys.ToList().Find(x => x.Function == hotKeyFunction); if (hkey == null) { Runtime.Instance.Settings.HotKeys.Add(hkey = new HotKey(hotKeyFunction)); } return(hkey); }
private int IndexOf(HotKeyFunction function) { for (int i = 0; i < this.Count; i++) { if (this[i].Function == function) { return(i); } } return(-1); }
public HotKey this[HotKeyFunction function] { get { return(this.Find(function)); } set { int index = this.IndexOf(function); if (index == -1) { this.Add(value); } else { this[index] = value; } } }
public HotKey GetHotKeyByFunction(HotKeyFunction function) { return(this.HotKeys.FirstOrDefault(hotKey => hotKey.Function == function) ?? new HotKey(function)); }
public HotKey GetHotKeyByFunction(HotKeyFunction function) { return this.HotKeys.FirstOrDefault(hotKey => hotKey.Function == function) ?? new HotKey(function); }
public HotKey(HotKeyFunction function) : this() { this.Function = function; }
public HotKey Find(HotKeyFunction function) { return(this.FirstOrDefault(item => item.Function.Equals(function))); }
public bool Exists(HotKeyFunction function) { return(this.Any(key => key.Function.Equals(function))); }