public static void SetShortcutForShow(KeyCombination? e) { setShortcut(e, "show", Toggl.SetKeyModifierShow, Toggl.SetKeyShow ); }
public void Combining_three_args_returns_new_arg_with_all_keys() { var space = new KeyCombination(Key.Space); var combination = _left && _right && space; combination.Should().NotBeNull(); combination.Keys.Should().HaveCount(3); combination.Keys.Should().Contain(Key.Left); combination.Keys.Should().Contain(Key.Right); combination.Keys.Should().Contain(Key.Space); }
public void CheckKeyCombination(KeyCombination kc) { if (!Config.EnableRandomizer) return; if (kc.Equals(Config.HotkeyRandomizerChance10)) { ShowRandomizer(Config.RandomizerChance10); } if (kc.Equals(Config.HotkeyRandomizerChance20)) { ShowRandomizer(Config.RandomizerChance20); } if (kc.Equals(Config.HotkeyRandomizerChance30)) { ShowRandomizer(Config.RandomizerChance30); } if (kc.Equals(Config.HotkeyRandomizerChance40)) { ShowRandomizer(Config.RandomizerChance40); } if (kc.Equals(Config.HotkeyRandomizerChance50)) { ShowRandomizer(Config.RandomizerChance50); } if (kc.Equals(Config.HotkeyRandomizerChance60)) { ShowRandomizer(Config.RandomizerChance60); } if (kc.Equals(Config.HotkeyRandomizerChance70)) { ShowRandomizer(Config.RandomizerChance70); } if (kc.Equals(Config.HotkeyRandomizerChance80)) { ShowRandomizer(Config.RandomizerChance80); } if (kc.Equals(Config.HotkeyRandomizerChance90)) { ShowRandomizer(Config.RandomizerChance90); } }
public void SubscribeKey(KeyCombination keyCombination, CombinationDirection keyargDirection, Action action) { var keyArgActionPair = new KeyArgActionPair { KeyCombination = keyCombination, Action = action }; if ((keyargDirection & CombinationDirection.Up) == CombinationDirection.Up) { _keyArgUpPairs.Add(keyArgActionPair); } if ((keyargDirection & CombinationDirection.Down) == CombinationDirection.Down) { _keyArgDownPairs.Add(keyArgActionPair); } GenerateLookups(); }
public bool Equals(KeyCombination combination, Key key) { if (Combination != combination) return false; if (KeySet == null) { if (key == Key) return true; } else { if (KeySet.Contains(key)) return true; } return false; }
public TextBoxHotkey(bool restrictedToSingeKeys) { RestrictedToSingeKeys = restrictedToSingeKeys; KeyCombination = new KeyCombination(Key.None, false, false, false); BorderThickness = new Thickness(1.2); BorderBrush = Brushes.DarkGray; IsReadOnly = true; Background = Brushes.AliceBlue; SelectionBrush = Brushes.Transparent; VerticalContentAlignment = VerticalAlignment.Center; ToolTip = "Double click mouse to remove hotkey"; Padding = new Thickness(0); GotFocus += (sender, args) => { BorderBrush = Brushes.Red; if (App.KeyboardHook != null) { App.KeyboardHook.KeyCombinationDownMethods.Add(TextBoxKeyDown); } }; LostFocus += (sender, args) => { BorderBrush = Brushes.DarkGray; if (App.KeyboardHook != null) { App.KeyboardHook.KeyCombinationDownMethods.Remove(TextBoxKeyDown); } }; MouseDoubleClick += (sender, args) => { KeyCombination = new KeyCombination(Key.None, false, false, false); }; TextWrapping = TextWrapping.NoWrap; }
public void RegisterKeyListener(KeyCombination keyCombination, Action keyAction) { keyActions.Add(new KeyValuePair <KeyCombination, Action>(keyCombination, keyAction)); }
private void KeyArgDown(KeyCombination keyCombination) { _keyArgsDown.Add(keyCombination); FireKeyArgDown(keyCombination); }
public void TestLeftRightModifierHandling(KeyCombination candidate, KeyCombination pressed, KeyCombinationMatchingMode matchingMode, bool shouldContain) => Assert.AreEqual(shouldContain, KeyCombination.ContainsAll(candidate.Keys, pressed.Keys, matchingMode));
// private Tile mech private void Tile(KeyCombination kc) { // collect info List <TableTileAndTableInfos> ttatis = _tableTiles.Where(o => o.IsEnabled && o.KeyCombination.Equals(kc)).Select(tableTile => new TableTileAndTableInfos { TableTile = tableTile, TableInfos = new List <TableInfo>() }).ToList(); if (ttatis.Any()) { // get all windows info var windowsInfo = new List <HandleTitleClass>(); foreach (var handle in WinApi.GetWindowHWndAll().Where(o => !Methods.IsMinimized(o))) { windowsInfo.Add(new HandleTitleClass { Handle = handle, Title = WinApi.GetWindowTitle(handle), Class = WinApi.GetClassName(handle) }); } // checkif and tile foreach (var ttati in ttatis) { // check how many tables match regextitle/regexclass var windowsMatchRegexes = windowsInfo.Where(a => ttati.TableTile.RegexWindowClass.IsMatch(a.Class) && ttati.TableTile.RegexWindowTitle.IsMatch(a.Title)).ToArray(); if (windowsMatchRegexes.Any() && ttati.TableTile.TableCountEqualOrGreaterThan <= windowsMatchRegexes.Length && windowsMatchRegexes.Length <= ttati.TableTile.TableCountEqualOrLessThan) { foreach (var windowInfo in windowsMatchRegexes) { // table tile config has valid targets TableInfo ti = new TableInfo { Handle = windowInfo.Handle, Title = windowInfo.Title, CurrentRectangle = WinApi.GetWindowRectangle(windowInfo.Handle) }; Match match = _regexTournamentNumber.Match(windowInfo.Title); if (match.Success) { ti.IsTournament = long.TryParse(match.Groups["tournament_number"].Value, out ti.TournamentNumber); Tournament tournament = App.HandHistoryManager.GetTournament(ti.TournamentNumber); if (tournament != null) { ti.FirstHandTimestamp = tournament.GetFirstHandTimestampET(); } else { ti.FirstHandTimestamp = DateTime.MaxValue; } } else { ti.IsTournament = false; ti.FirstHandTimestamp = DateTime.MaxValue; } ttati.TableInfos.Add(ti); } } } // tile foreach (var ttati in ttatis) { Tile(ttati); } } }
private bool OnToggleSprintHotKey(KeyCombination t1) { _isSprintToggled = !_isSprintToggled; _clientApi.World.Player.Entity.Controls.Sprint = true; return(true); }
public void AddBinding(KeyCombination combination, Action<Key> command, params Key[] keys) { AddBinding(new KeyboardBinding(combination, command, keys)); }
public override void HandleKeyboard(ISystemContainer systemContainer, KeyCombination keyboard) { }
public static void SetShortcutForStart(KeyCombination? e) { setShortcut(e, "start", (s, m) => s.StartModifiers = m, (s, k) => s.StartKey = k ); }
public static void SetShortcutForStart(KeyCombination? e) { try { if (e.HasValue) { Properties.Settings.Default.StartModifiers = e.Value.Modifiers; Properties.Settings.Default.StartKey = e.Value.KeyCode; } else { Properties.Settings.Default.StartModifiers = 0; Properties.Settings.Default.StartKey = null; } Properties.Settings.Default.Save(); } catch (Exception ex) { Console.WriteLine("Could not set shortcut for start: {0}", ex); } }
public abstract void HandleKeyboard(ISystemContainer systemContainer, KeyCombination keyboard);
public void SetUp() { _removal = Key.Back; _kc = new KeyCombination(); }
public KeyboardBinding(KeyCombination combination, Action<Key> command, params Key[] keys) { Combination = combination; ParameterizedCommand = command; KeySet = keys; }
public KeyboardBinding(KeyCombination combination, Key key, Action command) { Combination = combination; Key = key; Command = command; }
private MatchKind CheckKeyCombination(KeyCombination combination, VirtualKey keyAdded, KeyCombination precedingCombination = null) { // A key gesture is defined by either explicit modifier keys in both combinations // or no modifiers specified for second combination, // but then the second combination works with either no modifiers or same modifiers as the first. // A gesture is rejected if a combination with unrecognized non-modifier key is used. var downState = CoreVirtualKeyStates.Down; var ctrl = (this.window.CoreWindow.GetKeyState(VirtualKey.Control) & downState) == downState; var alt = (this.window.CoreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState; var shift = (this.window.CoreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState; if (!keyAdded.IsModifier()) { if (combination.Contains(keyAdded)) { foreach (var key in combination) { if (key == keyAdded) { continue; } if ((this.window.CoreWindow.GetKeyState(key) & downState) != downState) { // Missing some modifier key return MatchKind.Mismatch; } } // All the keys matched! // Reject if found additional modifiers pressed if (ctrl && (!combination.Contains(VirtualKey.Control) && (precedingCombination == null || !precedingCombination.Contains(VirtualKey.Control))) || alt && (!combination.Contains(VirtualKey.Menu) || (precedingCombination == null || !precedingCombination.Contains(VirtualKey.Menu))) || shift && (!combination.Contains(VirtualKey.Shift) || (precedingCombination == null || !precedingCombination.Contains(VirtualKey.Shift)))) { return MatchKind.Mismatch; } return MatchKind.Match; } else { // An invalid non-modifier key was pressed return MatchKind.Mismatch; } } else { // Only recognizing combinations when a non-modifier key is pressed return MatchKind.Incomplete; } }
public void TestKeyCombinationDisplayOrder(KeyCombination keyCombination, string expectedRepresentation) => Assert.That(keyCombination.ReadableString(), Is.EqualTo(expectedRepresentation));
private static void setShortcut(KeyCombination? e, string shortcutName, Action<Settings, ModifierKeys> setModifier, Action<Settings, string> setKey) { try { if (e.HasValue) { setModifier(Settings.Default, e.Value.Modifiers); setKey(Settings.Default, e.Value.KeyCode); } else { setModifier(Settings.Default, 0); setKey(Settings.Default, null); } Settings.Default.Save(); } catch (Exception ex) { Toggl.Debug(string.Format("Could not set shortcut for {0}: {1}", shortcutName, ex)); } }
private void FireKeyArgUp(KeyCombination keyCombination) { var actions = _keyArgUpLookUp[keyCombination]; FireKeyActionPairActions(actions); }
public void Start() { Stop(); _thread = new Thread(() => { while (true) { try { Thread.Sleep(100); lock (_lockKeyCombination) { if (_keyCombinationPressed != null) { _busy = true; Tile(_keyCombinationPressed); _keyCombinationPressed = null; _busy = false; } } lock (_lockAutoTile) { if (_tablesToAutoTile.Any()) { List<AutoTileWithTimestamp> toRemove = new List<AutoTileWithTimestamp>(); foreach (var item in _tablesToAutoTile) { bool autoTileSucessful = AutoTile(item.TableToAutoTile); if (autoTileSucessful) { toRemove.Add(item); } } toRemove.AddRange(_tablesToAutoTile.Where(o => o.Added.AddMilliseconds(Config.AutoTileCheckingTimeMs) < DateTime.Now)); foreach (var item in toRemove) _tablesToAutoTile.Remove(item); } } } catch (Exception e) { if (e is ThreadInterruptedException) { break; } } } }); _thread.Start(); }
private void KeyArgUp(KeyCombination keyCombination) { _keyArgsDown.Remove(keyCombination); FireKeyArgUp(keyCombination); }
public static string GetString(KeyCombination keyCombination) { List<string> modifiers = new List<string>(); if (keyCombination.Ctrl) { modifiers.Add("Ctrl"); modifiers.Add(" + "); } if (keyCombination.Alt) { modifiers.Add("Alt"); modifiers.Add(" + "); } if (keyCombination.Shift) { modifiers.Add("Shift"); modifiers.Add(" + "); } StringBuilder sb = new StringBuilder(); foreach (string s in modifiers) sb.Append(s); sb.Append(keyCombination.Key); return sb.ToString(); }
public void AddBinding(KeyCombination combination, Key key, Action command) { AddBinding(new KeyboardBinding(combination, key, command)); }
private void TextBoxKeyDown(KeyCombination keyCombination) { Window parentWindow = Window.GetWindow(this); if (parentWindow != null && parentWindow.WindowState != WindowState.Minimized) { if (new WindowInteropHelper(parentWindow).Handle == WinApi.GetActiveWindow()) { if (RestrictedToSingeKeys) { keyCombination.Alt = false; keyCombination.Shift = false; keyCombination.Ctrl = false; } KeyCombination = keyCombination; } } }
public void UpdateKeyCombination(KeyCombination newCombination) { KeyBinding.KeyCombination = newCombination; Text.Text = KeyBinding.KeyCombination.ReadableString(); }
public ShortcutKeyInfo(EmulatorShortcut key, KeyCombination keyCombination) { Shortcut = key; KeyCombination = keyCombination; }
public void InitializeGrid(PreferencesConfig config) { _config = config; EmulatorShortcut[] displayOrder = new EmulatorShortcut[] { EmulatorShortcut.FastForward, EmulatorShortcut.ToggleFastForward, EmulatorShortcut.Rewind, EmulatorShortcut.ToggleRewind, EmulatorShortcut.RewindTenSecs, EmulatorShortcut.RewindOneMin, EmulatorShortcut.Pause, EmulatorShortcut.Reset, EmulatorShortcut.PowerCycle, EmulatorShortcut.ReloadRom, EmulatorShortcut.PowerOff, EmulatorShortcut.Exit, EmulatorShortcut.TakeScreenshot, EmulatorShortcut.RunSingleFrame, EmulatorShortcut.SetScale1x, EmulatorShortcut.SetScale2x, EmulatorShortcut.SetScale3x, EmulatorShortcut.SetScale4x, EmulatorShortcut.SetScale5x, EmulatorShortcut.SetScale6x, EmulatorShortcut.ToggleFullscreen, EmulatorShortcut.ToggleDebugInfo, EmulatorShortcut.ToggleFps, EmulatorShortcut.ToggleGameTimer, EmulatorShortcut.ToggleFrameCounter, EmulatorShortcut.ToggleOsd, EmulatorShortcut.ToggleAlwaysOnTop, EmulatorShortcut.ToggleCheats, EmulatorShortcut.ToggleBgLayer0, EmulatorShortcut.ToggleBgLayer1, EmulatorShortcut.ToggleBgLayer2, EmulatorShortcut.ToggleBgLayer3, EmulatorShortcut.ToggleSprites, EmulatorShortcut.EnableAllLayers, EmulatorShortcut.ToggleAudio, EmulatorShortcut.IncreaseVolume, EmulatorShortcut.DecreaseVolume, EmulatorShortcut.MaxSpeed, EmulatorShortcut.IncreaseSpeed, EmulatorShortcut.DecreaseSpeed, EmulatorShortcut.OpenFile, EmulatorShortcut.LoadRandomGame, EmulatorShortcut.MoveToNextStateSlot, EmulatorShortcut.MoveToPreviousStateSlot, EmulatorShortcut.SaveState, EmulatorShortcut.LoadState, EmulatorShortcut.SaveStateSlot1, EmulatorShortcut.SaveStateSlot2, EmulatorShortcut.SaveStateSlot3, EmulatorShortcut.SaveStateSlot4, EmulatorShortcut.SaveStateSlot5, EmulatorShortcut.SaveStateSlot6, EmulatorShortcut.SaveStateSlot7, EmulatorShortcut.SaveStateSlot8, EmulatorShortcut.SaveStateSlot9, EmulatorShortcut.SaveStateSlot10, EmulatorShortcut.SaveStateToFile, EmulatorShortcut.SaveStateDialog, EmulatorShortcut.LoadStateSlot1, EmulatorShortcut.LoadStateSlot2, EmulatorShortcut.LoadStateSlot3, EmulatorShortcut.LoadStateSlot4, EmulatorShortcut.LoadStateSlot5, EmulatorShortcut.LoadStateSlot6, EmulatorShortcut.LoadStateSlot7, EmulatorShortcut.LoadStateSlot8, EmulatorShortcut.LoadStateSlot9, EmulatorShortcut.LoadStateSlot10, EmulatorShortcut.LoadStateFromFile, EmulatorShortcut.LoadStateDialog, EmulatorShortcut.SelectSaveSlot1, EmulatorShortcut.SelectSaveSlot2, EmulatorShortcut.SelectSaveSlot3, EmulatorShortcut.SelectSaveSlot4, EmulatorShortcut.SelectSaveSlot5, EmulatorShortcut.SelectSaveSlot6, EmulatorShortcut.SelectSaveSlot7, EmulatorShortcut.SelectSaveSlot8, EmulatorShortcut.SelectSaveSlot9, EmulatorShortcut.SelectSaveSlot10 }; HashSet <string> keyCombinations = new HashSet <string>(); foreach (EmulatorShortcut shortcut in displayOrder) { int i = gridShortcuts.Rows.Add(); gridShortcuts.Rows[i].Cells[0].Tag = shortcut; gridShortcuts.Rows[i].Cells[0].Value = ResourceHelper.GetMessage("EmulatorShortcutMappings_" + shortcut.ToString()); int keyIndex = config.ShortcutKeys1.FindIndex((ShortcutKeyInfo shortcutInfo) => shortcutInfo.Shortcut == shortcut); if (keyIndex >= 0) { KeyCombination keyComb = config.ShortcutKeys1[keyIndex].KeyCombination; keyCombinations.Add(keyComb.ToString()); gridShortcuts.Rows[i].Cells[1].Value = keyComb.ToString(); gridShortcuts.Rows[i].Cells[1].Tag = keyComb; } keyIndex = config.ShortcutKeys2.FindIndex((ShortcutKeyInfo shortcutInfo) => shortcutInfo.Shortcut == shortcut); if (keyIndex >= 0) { KeyCombination keyComb = config.ShortcutKeys2[keyIndex].KeyCombination; keyCombinations.Add(keyComb.ToString()); gridShortcuts.Rows[i].Cells[2].Value = keyComb.ToString(); gridShortcuts.Rows[i].Cells[2].Tag = keyComb; } } CheckConflicts(); }
private void InitializeGrid() { EmulatorShortcut[] displayOrder = new EmulatorShortcut[] { EmulatorShortcut.FastForward, EmulatorShortcut.ToggleFastForward, EmulatorShortcut.Rewind, EmulatorShortcut.ToggleRewind, EmulatorShortcut.RewindTenSecs, EmulatorShortcut.RewindOneMin, EmulatorShortcut.Pause, EmulatorShortcut.Reset, EmulatorShortcut.PowerCycle, EmulatorShortcut.PowerOff, EmulatorShortcut.Exit, EmulatorShortcut.InsertNextDisk, EmulatorShortcut.SwitchDiskSide, EmulatorShortcut.EjectDisk, EmulatorShortcut.InsertCoin1, EmulatorShortcut.InsertCoin2, EmulatorShortcut.VsServiceButton, EmulatorShortcut.InputBarcode, EmulatorShortcut.TakeScreenshot, EmulatorShortcut.LoadRandomGame, EmulatorShortcut.RunSingleFrame, EmulatorShortcut.SetScale1x, EmulatorShortcut.SetScale2x, EmulatorShortcut.SetScale3x, EmulatorShortcut.SetScale4x, EmulatorShortcut.SetScale5x, EmulatorShortcut.SetScale6x, EmulatorShortcut.ToggleFullscreen, EmulatorShortcut.ToggleDebugInfo, EmulatorShortcut.ToggleFps, EmulatorShortcut.ToggleGameTimer, EmulatorShortcut.ToggleFrameCounter, EmulatorShortcut.ToggleLagCounter, EmulatorShortcut.ToggleOsd, EmulatorShortcut.ToggleAlwaysOnTop, EmulatorShortcut.ToggleBackground, EmulatorShortcut.ToggleSprites, EmulatorShortcut.ToggleCheats, EmulatorShortcut.ToggleAudio, EmulatorShortcut.ToggleKeyboardMode, EmulatorShortcut.MaxSpeed, EmulatorShortcut.IncreaseSpeed, EmulatorShortcut.DecreaseSpeed, EmulatorShortcut.OpenFile, EmulatorShortcut.MoveToNextStateSlot, EmulatorShortcut.MoveToPreviousStateSlot, EmulatorShortcut.SaveState, EmulatorShortcut.LoadState, EmulatorShortcut.SaveStateSlot1, EmulatorShortcut.SaveStateSlot2, EmulatorShortcut.SaveStateSlot3, EmulatorShortcut.SaveStateSlot4, EmulatorShortcut.SaveStateSlot5, EmulatorShortcut.SaveStateSlot6, EmulatorShortcut.SaveStateSlot7, EmulatorShortcut.SaveStateSlot8, EmulatorShortcut.SaveStateSlot9, EmulatorShortcut.SaveStateSlot10, EmulatorShortcut.SaveStateToFile, EmulatorShortcut.LoadStateSlot1, EmulatorShortcut.LoadStateSlot2, EmulatorShortcut.LoadStateSlot3, EmulatorShortcut.LoadStateSlot4, EmulatorShortcut.LoadStateSlot5, EmulatorShortcut.LoadStateSlot6, EmulatorShortcut.LoadStateSlot7, EmulatorShortcut.LoadStateSlot8, EmulatorShortcut.LoadStateSlot9, EmulatorShortcut.LoadStateSlot10, EmulatorShortcut.LoadStateSlotAuto, EmulatorShortcut.LoadStateFromFile, EmulatorShortcut.LoadLastSession, }; HashSet <string> keyCombinations = new HashSet <string>(); foreach (EmulatorShortcut shortcut in displayOrder) { int i = gridShortcuts.Rows.Add(); gridShortcuts.Rows[i].Cells[0].Tag = shortcut; gridShortcuts.Rows[i].Cells[0].Value = ResourceHelper.GetMessage("EmulatorShortcutMappings_" + shortcut.ToString()); int keyIndex = ConfigManager.Config.PreferenceInfo.ShortcutKeys1.FindIndex((ShortcutKeyInfo shortcutInfo) => shortcutInfo.Shortcut == shortcut); if (keyIndex >= 0) { KeyCombination keyComb = ConfigManager.Config.PreferenceInfo.ShortcutKeys1[keyIndex].KeyCombination; keyCombinations.Add(keyComb.ToString()); gridShortcuts.Rows[i].Cells[1].Value = keyComb.ToString(); gridShortcuts.Rows[i].Cells[1].Tag = keyComb; } keyIndex = ConfigManager.Config.PreferenceInfo.ShortcutKeys2.FindIndex((ShortcutKeyInfo shortcutInfo) => shortcutInfo.Shortcut == shortcut); if (keyIndex >= 0) { KeyCombination keyComb = ConfigManager.Config.PreferenceInfo.ShortcutKeys2[keyIndex].KeyCombination; keyCombinations.Add(keyComb.ToString()); gridShortcuts.Rows[i].Cells[2].Value = keyComb.ToString(); gridShortcuts.Rows[i].Cells[2].Tag = keyComb; } } CheckConflicts(); }
/// <summary> /// Construct a new instance. /// </summary> /// <param name="keys">The combination of keys which will trigger this binding.</param> /// <param name="action">The resultant action which is triggered by this binding. Usually an enum type.</param> public KeyBinding(KeyCombination keys, object action) { KeyCombination = keys; Action = action; }
private static extern int EOS_UI_IsValidKeyCombination(IntPtr handle, KeyCombination keyCombination);
public PreferencesViewModelWithSampleData(IEventAggregator aggregator, IPreferencesSerializer serializer) : base(aggregator, serializer) { DebugAllShortcut = new KeyCombination(Key.LeftCtrl, Key.LeftAlt, Key.MediaPlayPause); StartAllShortcut = new KeyCombination(Key.LeftCtrl, Key.LeftAlt, Key.LeftShift, Key.MediaPlayPause); }
/// <summary> /// Initializes a new instance of the KeyboardHook class. /// </summary> public KeyboardHook() { hookCallback = HookCallBack; Combination = new KeyCombination(KeysEx.None); }
private bool OnHotkeyWorldEdit(KeyCombination t1) { TriggerWorldEditDialog(); return(true); }
/// <summary> /// Removes the keys associated with this hook. This can only be performed when the hook is not active. /// </summary> /// <exception cref="InvalidOperationException">Occurs if the hook is currently engaged.</exception> public void RemoveKeys() { if (Combination.Keys == KeysEx.None) return; if (IsEngaged) throw new InvalidOperationException("Cannot remove keys while hook is engaged."); if (Combination != null && currentHookKeys.Contains(Combination)) currentHookKeys.Remove(Combination); Combination = new KeyCombination(KeysEx.None); }
/// <summary> /// Associates the specified key combination with this hook. This can only be performed when the hook is not active. /// </summary> /// <param name="combination">The key combination.</param> /// <exception cref="InvalidOperationException">Occurs if this hook is currently engaged -OR- if the key combination is invalid /// -OR- if the key combination is already in use by another hook.</exception> public void SetKeys(KeyCombination combination) { if (Combination == combination) return; if (IsEngaged) throw new InvalidOperationException("Cannot set keys while hook is engaged."); if (!combination.IsValid) throw new InvalidOperationException("Key combination is not valid."); if (currentHookKeys.Contains(combination)) throw new InvalidOperationException(string.Format("The combination '{0}' is already in use.", combination)); if (Combination != null && currentHookKeys.Contains(Combination)) currentHookKeys.Remove(Combination); currentHookKeys.Add(combination); Combination = combination; }
/// <summary> /// Determines whether the specified key, combined with all currently pressed modifier keys, matches this hook's key combination. /// </summary> /// <param name="unmodifiedKey">The unmodified key to combine with all currently pressed keyboard modifier keys.</param> /// <returns>True if unmodifiedKey matches Combination.UnmodifiedKey and all modifier keys contained in the /// Combination property are currently pressed; otherwise, false.</returns> protected bool CheckIsHookKeyCombination(KeysEx unmodifiedKey) { KeyCombination pressedKeyCombo = new KeyCombination(unmodifiedKey); if (IsKeyPressed(KeysEx.ControlKey)) pressedKeyCombo.Add(KeysEx.Control); if (IsKeyPressed(KeysEx.ShiftKey)) pressedKeyCombo.Add(KeysEx.Shift); if (IsKeyPressed(KeysEx.LMenu) || IsKeyPressed(KeysEx.RMenu)) pressedKeyCombo.Add(KeysEx.Alt); if ((IsKeyPressed(KeysEx.LWin) || IsKeyPressed(KeysEx.RWin))) pressedKeyCombo.Add(KeysEx.WinLogo); return Combination == pressedKeyCombo; }
private bool OnHotKeyWorldMapDlg(KeyCombination comb) { ToggleMap(EnumDialogType.Dialog); return(true); }
/// <summary> /// Determines whether the specified key combination is already in use. /// </summary> /// <param name="combination">The combination to check.</param> /// <returns>True if the key combination is already in use; otherwise, false.</returns> public static bool IsKeyCombinationTaken(KeyCombination combination) { return currentHookKeys.Contains(combination); }
public static void SetShortcutForShow(KeyCombination? e) { setShortcut(e, "show", (s, m) => s.ShowModifiers = m, (s, k) => s.ShowKey = k ); }
public static void SetShortcutForStart(KeyCombination? e) { setShortcut(e, "start", Toggl.SetKeyModifierStart, Toggl.SetKeyStart ); }
public void SetKeyCombination(KeyCombination keyCombination) { if (!Config.EnableTableTiler) return; if (!_busy) { lock (_lockKeyCombination) { _keyCombinationPressed = keyCombination; } } }
private void ProcessKeyArg(KeyCombination keyCombination) { var keyDictionary = _keyboardInputProcessor.KeyDictionary; var isArgumentTrue = keyCombination.IsArgumentTrue(keyDictionary); var keyArgIsDown = _keyArgsDown.Contains(keyCombination); if (isArgumentTrue && !keyArgIsDown) { KeyArgDown(keyCombination); } else if (!isArgumentTrue && keyArgIsDown) { KeyArgUp(keyCombination); } }
// private Tile mech private void Tile(KeyCombination kc) { // collect info List<TableTileAndTableInfos> ttatis = _tableTiles.Where(o => o.IsEnabled && o.KeyCombination.Equals(kc)).Select(tableTile => new TableTileAndTableInfos { TableTile = tableTile, TableInfos = new List<TableInfo>() }).ToList(); if (ttatis.Any()) { // get all windows info var windowsInfo = new List<HandleTitleClass>(); foreach (var handle in WinApi.GetWindowHWndAll().Where(o => !Methods.IsMinimized(o))) { windowsInfo.Add(new HandleTitleClass { Handle = handle, Title = WinApi.GetWindowTitle(handle), Class = WinApi.GetClassName(handle) }); } // checkif and tile foreach (var ttati in ttatis) { // check how many tables match regextitle/regexclass var windowsMatchRegexes = windowsInfo.Where(a => ttati.TableTile.RegexWindowClass.IsMatch(a.Class) && ttati.TableTile.RegexWindowTitle.IsMatch(a.Title)).ToArray(); if (windowsMatchRegexes.Any() && ttati.TableTile.TableCountEqualOrGreaterThan <= windowsMatchRegexes.Length && windowsMatchRegexes.Length <= ttati.TableTile.TableCountEqualOrLessThan) { foreach (var windowInfo in windowsMatchRegexes) { // table tile config has valid targets TableInfo ti = new TableInfo { Handle = windowInfo.Handle, Title = windowInfo.Title, CurrentRectangle = WinApi.GetWindowRectangle(windowInfo.Handle) }; Match match = _regexTournamentNumber.Match(windowInfo.Title); if (match.Success) { ti.IsTournament = long.TryParse(match.Groups["tournament_number"].Value, out ti.TournamentNumber); Tournament tournament = App.HandHistoryManager.GetTournament(ti.TournamentNumber); if (tournament != null) { ti.FirstHandTimestamp = tournament.GetFirstHandTimestampET(); } else { ti.FirstHandTimestamp = DateTime.MaxValue; } } else { ti.IsTournament = false; ti.FirstHandTimestamp = DateTime.MaxValue; } ttati.TableInfos.Add(ti); } } } // tile foreach (var ttati in ttatis) { Tile(ttati); } } }
internal static extern int EOS_UI_IsValidKeyCombination(System.IntPtr handle, KeyCombination keyCombination);