public KeyAssign(Key key, ModifierKeys modifiers, IEnumerable<KeyAssignActionDescription> actions, bool handlePreview = false) { Key = key; Modifiers = modifiers; HandlePreview = handlePreview; Actions = actions.ToArray(); }
public void AddKeyBinding(ICommand command, object param, Key key, ModifierKeys modifierKeys = ModifierKeys.None) { Contract.Requires(command != null); var binding = new KeyBinding(key, modifierKeys); m_keyBindings.Add(binding, new CommandParamPair(command, param)); }
protected override void OnLoading() { base.OnLoading(); var element = Controller.Element; _modifiersKeys = MouseWheel.GetVScrollModifiers(element); MouseWheel.VScrollModifiersProperty.AddValueChanged(element, OnModifierKeysYChanged); }
public HotKey(int id, Key key, ModifierKeys modifiers) { this.id = id; this.key = key; this.modifiers = modifiers; this.actions = new List<Action>(); }
public static void HookHotKey(Window window, Key key, ModifierKeys modifiers, int keyId, EventHandler hookHandler) { HwndSourceHook hook = delegate(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { if (msg == HotKeyHelper.WM_HOTKEY) { // TODO: parse out the lParam to see if it is actually the one registered // see http://msdn.microsoft.com/en-us/library/ms646279(VS.85).aspx hookHandler(window, EventArgs.Empty); handled = true; } return IntPtr.Zero; }; HwndSource source = PresentationSource.FromVisual(window) as HwndSource; if (source == null) { throw new ApplicationException("window doesn't have a source yet. Did you wait till after the SourceInitialized event?"); } source.AddHook(hook); RegisterHotKey(window, key, modifiers, keyId); }
/// <summary> /// Регистрация хоткея в системе /// </summary> /// <param name="modifier">Модификатор хоткея.</param> /// <param name="key">Клавиша хоткея.</param> public void RegisterHotKey(ModifierKeys modifier, Keys key) { _currentId = _currentId + 1; if (!NativeMethods.RegisterHotKey(_window.Handle, _currentId, (uint)modifier, (uint)key)) { throw new InvalidOperationException("Couldn’t register the hot key."); } }
public void Select(ModifierKeys modifierKey, ICollection<ITreeItem> rootTreeItems, ITreeItem newSelectedItem, ITreeItem oldSelectedItem) { switch (modifierKey) { case ModifierKeys.Shift: if(_previousSelectionWasShift) { _rangeSelector.Select(rootTreeItems, newSelectedItem, _previousShiftSelection); } else { _rangeSelector.Select(rootTreeItems, newSelectedItem, oldSelectedItem); _previousShiftSelection = oldSelectedItem; } _previousSelectionWasShift = true; break; case ModifierKeys.Control: _previousSelectionWasShift = false; _inverseSelector.Select(rootTreeItems, newSelectedItem); break; default: _previousSelectionWasShift = false; _nullSelector.Select(rootTreeItems, newSelectedItem); break; } }
/// <summary> /// Try and get the KeyInput which corresponds to the given Key and modifiers /// TODO: really think about this method /// </summary> internal bool TryGetKeyInput(Key key, ModifierKeys modifierKeys, out KeyInput keyInput) { // First just check and see if there is a direct mapping var keyType = new KeyType(key, modifierKeys); if (_cache.TryGetValue(keyType, out keyInput)) { return true; } // Next consider only the shift key part of the requested modifier. We can // re-apply the original modifiers later keyType = new KeyType(key, modifierKeys & ModifierKeys.Shift); if (_cache.TryGetValue(keyType, out keyInput)) { // Reapply the modifiers keyInput = KeyInputUtil.ChangeKeyModifiers(keyInput, ConvertToKeyModifiers(modifierKeys)); return true; } // Last consider it without any modifiers and reapply keyType = new KeyType(key, ModifierKeys.None); if (_cache.TryGetValue(keyType, out keyInput)) { // Reapply the modifiers keyInput = KeyInputUtil.ChangeKeyModifiers(keyInput, ConvertToKeyModifiers(modifierKeys)); return true; } return false; }
/// <summary> /// Determines whether the event arguments match the specified key combination. /// </summary> /// <param name="key">The key.</param> /// <param name="modifierKeys">The modifier keys.</param> /// <returns>True if the event arguments match the specified key combination, otherwise false.</returns> public bool Match(Key key, ModifierKeys modifierKeys = ModifierKeys.None) { if (this.Key == key) { if (key == Keyboard.LeftControl || key == Keyboard.RightControl) { return (this.ModifierKeys | ModifierKeys.Control) == (modifierKeys | ModifierKeys.Control); } if (key == Keyboard.LeftAlt || key == Keyboard.RightAlt) { return (this.ModifierKeys | ModifierKeys.Alt) == (modifierKeys | ModifierKeys.Alt); } if (key == Keyboard.LeftShift || key == Keyboard.RightShift) { return (this.ModifierKeys | ModifierKeys.Shift) == (modifierKeys | ModifierKeys.Shift); } if (key == Keyboard.LeftWindows || key == Keyboard.RightWindows) { return (this.ModifierKeys | ModifierKeys.Windows) == (modifierKeys | ModifierKeys.Windows); } return this.ModifierKeys == modifierKeys; } return false; }
protected static KeyEventArgs CreateKeyEventArgs( Key key, ModifierKeys modKeys = ModifierKeys.None) { var device = new MockKeyboardDevice(InputManager.Current) { ModifierKeysImpl = modKeys }; return device.CreateKeyEventArgs(key, modKeys); }
public static Tuple<Keys, ModifierKeys> ConvertFromString(string keysString) { Keys mainKey = new Keys(); ModifierKeys modKeys = new ModifierKeys(); var keys = keysString.Split('+'); foreach (string keyString in keys) { Keys key = (Keys)(new KeysConverter()).ConvertFromString(keyString); if (key == Keys.Alt || key == Keys.LWin || key == Keys.Shift || key == Keys.Control) { switch (key) { case Keys.Alt: modKeys = modKeys | ModifierKeys.Alt; break; case Keys.LWin: modKeys = modKeys | ModifierKeys.Win; break; case Keys.Shift: modKeys = modKeys | ModifierKeys.Shift; break; case Keys.Control: modKeys = modKeys | ModifierKeys.Control; break; } } else { mainKey = key; } } return new Tuple<Keys, ModifierKeys>(mainKey, (ModifierKeys)modKeys); }
public void AddKeyBinding(string commandName, Key key, ModifierKeys modifierKeys = ModifierKeys.None) { Contract.Requires(!string.IsNullOrWhiteSpace(commandName)); Contract.Requires(HasCommand(commandName)); var binding = new KeyBinding(key, modifierKeys); m_keyBindings.Add(binding, commandName); }
public int RegisterHotKey(ModifierKeys mods, Keys key) { if (!RegisterHotKey(_window.Handle, ++_currentId, (uint) mods, (uint) key)) throw new Exception("Key register failed"); return _currentId; }
public void SaveKeys(ModifierKeys[] modifiers, Key key, ref String to) { String s = ""; modifiers.ToList().ForEach(k => s += k.ToString() + "+"); s += key.ToString(); to = s; }
public VertexSelectedEventArgs(VertexControl vc, MouseButtonEventArgs e, ModifierKeys keys) : base() { VertexControl = vc; MouseArgs = e; Modifiers = keys; }
KeyDescriptor (SpecialKey specialKey, char keyChar, ModifierKeys modifierKeys, object nativeKeyChar) { SpecialKey = specialKey; KeyChar = keyChar; ModifierKeys = modifierKeys; NativeKeyChar = nativeKeyChar; }
private void OnRunHotKeyPressed(Key key, ModifierKeys modifier) { if (state.IsConfigurationOpened) navigator.OpenConfiguration(); else navigator.OpenMain(); }
public static KeyInput ConvertToKeyInput(Key key, ModifierKeys modifierKeys) { var modKeys = ConvertToKeyModifiers(modifierKeys); var tuple = TryConvertToKeyInput(key); if (tuple == null) { return new KeyInput(Char.MinValue, modKeys); } if ((modKeys & KeyModifiers.Shift) == 0) { var temp = tuple.Item1; return new KeyInput(temp.Char, temp.Key, modKeys); } // The shift flag is tricky. There is no good API available to translate a virtualKey // with an additional modifier. Instead we define the core set of keys we care about, // map them to a virtualKey + ModifierKeys tuple. We then consult this map here to see // if we can appropriately "shift" the KeyInput value // // This feels like a very hackish solution and I'm actively seeking a better, more thorough // one var ki = tuple.Item1; var virtualKey = tuple.Item2; var found = MappedCoreChars.FirstOrDefault(x => x.Item2 == virtualKey && KeyModifiers.Shift == x.Item3); if (found == null) { return new KeyInput(ki.Char, modKeys); } else { return new KeyInput(found.Item1, modKeys); } }
/// <summary> /// Since our abilities implement a behavior (interface) and not a state (base class), serialization must be done /// manually. /// </summary> public void ReadXml(XmlReader reader) { var name = reader.GetAttribute("Name"); var specialization = reader.GetAttribute("Specialization"); var hotKey = reader.GetAttribute("Hotkey"); var modifierKey = reader.GetAttribute("Modifier"); reader.Read(); Name = name; WoWSpec outSpec; Enum.TryParse(specialization, out outSpec); Specialization = outSpec; Keys outHotKey; Enum.TryParse(hotKey, out outHotKey); HotKey = outHotKey; ModifierKeys outModifierKey; Enum.TryParse(modifierKey, out outModifierKey); ModiferKey = outModifierKey; var serializer = new XmlSerializer(ChainedAbilities.GetType()); ChainedAbilities = (List<ChainedAbility>) serializer.Deserialize(reader); reader.ReadEndElement(); }
public void KeyPushed(string key, ModifierKeys mod) { if (key == "space") { InputLine += " "; } else if (key == "return") { SendMessage(); } else if (key == "backspace") { InputLine = InputLine.Remove(InputLine.Length - 1); } else if (key == "tab") { InputLine += " "; Console.WriteLine(InputLine); } // Avoid unhandled special caracters else if (key.Length == 1) { if (mod == ModifierKeys.Caps || mod == ModifierKeys.ShiftKeys) key.ToUpper(); InputLine += key; } }
public void RegisterHotkey(ModifierKeys keyModifier, Keys hotkey) { HotkeySettings.Default.ModifierKey = keyModifier; HotkeySettings.Default.Key = hotkey; HotkeySettings.Default.Save(); Register(); }
void PanicKey_PreviewKeyDown(object sender, KeyEventArgs e) { e.Handled = true; var rKey = e.Key; switch (rKey) { case Key.LWin: case Key.RWin: case Key.NumLock: case Key.LeftShift: case Key.RightShift: case Key.LeftCtrl: case Key.RightCtrl: case Key.LeftAlt: case Key.RightAlt: return; } if (r_OldKey == rKey && r_OldModifierKeys == Keyboard.Modifiers) return; r_OldKey = rKey; r_OldModifierKeys = Keyboard.Modifiers; Preference.Instance.Other.PanicKey.UpdateKey((int)Keyboard.Modifiers, KeyInterop.VirtualKeyFromKey(rKey)); }
/// <summary> /// Initializes a new instance of the <see cref="Xwt.KeyEventArgs"/> class. /// </summary> /// <param name="key">The key.</param> /// <param name="modifiers">The modifier keys.</param> /// <param name="isRepeat">the key has been pressed more then once.</param> /// <param name="timestamp">The timestamp of the key event.</param> public KeyEventArgs (Key key, ModifierKeys modifiers, bool isRepeat, long timestamp) { this.Key = key; this.Modifiers = modifiers; this.IsRepeat = isRepeat; this.Timestamp = timestamp; }
/// <summary> /// Registers a hot key in the system. /// </summary> /// <param name="modifier">The modifiers that are associated with the hot key.</param> /// <param name="key">The key itself that is associated with the hot key.</param> public void RegisterHotKey(ModifierKeys modifier, Keys key) { // increment the counter. _currentId = _currentId + 1; // register the hot key. if (!RegisterHotKey(_window.Handle, _currentId, (uint)modifier, (uint)key)) throw new InvalidOperationException("Couldn’t register the hot key."); }
public static string GetString(Key key, ModifierKeys modifiers) { try { return (string)kgConverter.ConvertTo(new KeyGesture(key, modifiers), typeof(string)); } catch { return null; } }
public KeyGesture( VirtualKeys key, ModifierKeys modifiers, string displayString ) { if ( displayString == null ) throw new ArgumentNullException( "displayString" ); if ( !IsValid( key, modifiers ) ) throw new InvalidOperationException( "KeyGesture is invalid" ); this._modifiers = modifiers; this._key = key; this._displayString = displayString; }
public void ExecuteCommand(Key key, ModifierKeys modifiers) { Command command = GetCommand (key, modifiers); Action action; if (_commandMap.TryGetValue (command, out action)) { action.Invoke (); } }
public CustomGesture(Key key, ModifierKeys modifers) { this.key = key; this.modifers = modifers; if (modifers != ModifierKeys.None) this.useModifiers = true; }
public Hotkey(HotkeyFunction function, ModifierKeys modifier, Key key) { this.Function = function; this.Key = key; this.ModifierKey = modifier; SetDefaultParameterValues(); }
public AlphaToolDescriptor(string _name, EAlphaToolKind _kind, ModifierKeys _modifierKeys, Key _key, Func<FrameworkElement> _generateFunc) { Key = _key; GenerateFunc = _generateFunc; ModifierKeys = _modifierKeys; Kind = _kind; Name = _name; }
public static extern bool RegisterHotKey(IntPtr hWnd, int id, ModifierKeys fsModifiers, Keys vk);
public HotKey(Key key, ModifierKeys modifierKeys = ModifierKeys.None) { _key = key; _modifierKeys = modifierKeys; }
private void pictureBox_MouseMove(object sender, MouseEventArgs e) { int x = e.X / zoom; int y = e.Y / zoom; int tx = x / 16; int ty = y / 16; if (e.Button != MouseButtons.None && run_held == false) { int ti = ro + (tx * 12) + ty; if (mode == 0) { if (e.Button == MouseButtons.Left) { if (tx >= 0 && tx < 64 && ty >= 0 && ty < 12) { if (mp.rom_modify(ti, draw_tile, true)) { redraw(); mp.refresh_map(room); } } } else if (e.Button == MouseButtons.Right) { if (tx >= 0 && tx < 64 && ty >= 0 && ty < 12) { byte ndt = mp.rom[ti]; if (draw_tile != ndt) { set_draw_tile(-1, -1, ndt); } } } } else if (mode == 1 && drag_item >= 0) { int nx = x & (~15); // snap to grid int ny = y & (~15); if (ModifierKeys.HasFlag(Keys.Shift)) // Y can move freely with shift { ny = drag_item_y + (y - drag_y); } byte bx = (byte)(nx >> 4); byte by = (byte)(ny); bool changed = false; int romx = ro + 0x320 + (drag_item * 16) + 2; // item if (drag_item == 12) { romx = ro + 0x308; // treasure } int romy = romx + 1; changed |= mp.rom_modify(romx, bx, true); changed |= mp.rom_modify(romy, by, true); if (changed) { redraw(); redraw_info(); mp.refresh_map(room); } } } updateStatus(x, y); }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> public Shortcut(Key key, ModifierKeys modifier) : this() { Key = key; Modifier = modifier; }
static void AddBinding(ICommand command, ModifierKeys modifiers, Key key, ExecutedRoutedEventHandler handler) { CommandBindings.Add(new CommandBinding(command, handler)); InputBindings.Add(TextAreaDefaultInputHandler.CreateFrozenKeyBinding(command, modifiers, key)); }
/// <summary> /// Called on MouseUp event raised from Map Control when tool is activated. /// </summary> public void OnMouseUp(MouseButton pressedButton, ModifierKeys modifierKeys, double x, double y) { }
internal KeyPressedEventArgs(ModifierKeys modifier, Keys key) { _modifier = modifier; _key = key; }
/// <summary> /// Initializes a new instance of the <see cref="KeyBinding"/> class. /// </summary> /// <param name="command">The command associated with the specified gesture.</param> /// <param name="key">The key associated with the specified command.</param> /// <param name="modifiers">The key modifiers associated with the specified command.</param> public KeyBinding(ICommand command, Key key, ModifierKeys modifiers) : base(command, new KeyGesture(key, modifiers)) { }
/// <summary> /// Creates and adds a new hotkey to the hotkeys list. /// </summary> /// <param name="modifier">The modifier key. ALT Does not work.</param> /// <param name="key"></param> /// <param name="callbackMethod"></param> /// <param name="canExecute"></param> public static void AddHotkey(ModifierKeys modifier, Key key, Action callbackMethod, bool canExecute = true) { AddHotkey(new GlobalHotkey(modifier, key, callbackMethod, canExecute)); }
private void Form1_MouseDown(object sender, MouseEventArgs e) { mouseDownLocation = mouseStartLocation = e.Location; hasSecondSelected = false; // foreach shape check if mouse hits shape // - if(!ctrl pressed) selectedShapes.Clear() // - selectedShapes.add(shape) // else if no shape selected // - selectedShapes.Clear() if (hasSelected && ModifierKeys.HasFlag(Keys.Control)) { foreach (Shape s in shapeList) { if (s.dimension.Contains(e.Location)) { Shape temp = this.SelectedShape; Command selectShape = new SelectShapeCommand(s, this); history.Add(selectShape); this.SelectedShape = temp; SecondSelectedShape = s; shapeStartPosition = s.dimension.Location; hasSecondSelected = true; ResizeShapeButton.Enabled = true; Invalidate(); return; } } return; } else { hasSelected = false; // Op geselecteerde shape gedrukt dus er hoeft niks te gebeuren if (SelectedShape != null && SelectedShape.dimension.Contains(e.Location)) { shapeStartPosition = SelectedShape.dimension.Location; hasSelected = true; return; } } // check overige shape of er 1 geselecteerd foreach (Shape s in shapeList) { if (s.dimension.Contains(e.Location)) { Command selectShape = new SelectShapeCommand(s, this); history.Add(selectShape); shapeStartPosition = s.dimension.Location; hasSelected = true; ResizeShapeButton.Enabled = true; Invalidate(); return; } } // in de void gedrukt if (SelectedShape != null) { Command deselectShape = new SelectShapeCommand(null, this); history.Add(deselectShape); ResizeShapeButton.Enabled = false; Invalidate(); } }
public MouseWheelGesture(ModifierKeys keys, MouseWheelDirection direction) : base(MouseAction.WheelClick, keys) { Direction = direction; }
/// <summary> /// Creates an HotKey object. This instance has to be registered in an HotKeyHost. /// </summary> /// <param name="key">The key</param> /// <param name="modifiers">The modifier. Multiple modifiers can be combined with or.</param> public HotKey(Key key, ModifierKeys modifiers) : this(key, modifiers, true) { }
public ListWindowKeyAction ProcessKey(Key key, ModifierKeys modifier) { switch (key) { case Key.Up: if (list.SelectionDisabled) { list.SelectionDisabled = false; } else { list.Selection--; } return(ListWindowKeyAction.Ignore); case Key.Down: if (list.SelectionDisabled) { list.SelectionDisabled = false; } else { list.Selection++; } return(ListWindowKeyAction.Ignore); case Key.PageUp: list.Selection -= list.VisibleRows - 1; return(ListWindowKeyAction.Ignore); case Key.PageDown: list.Selection += list.VisibleRows - 1; return(ListWindowKeyAction.Ignore); case Key.Left: //if (curPos == 0) return KeyAction.CloseWindow | KeyAction.Process; //curPos--; return(ListWindowKeyAction.Process); case Key.BackSpace: if (curPos == 0 || (modifier & ModifierKeys.Control) != 0) { return(ListWindowKeyAction.CloseWindow | ListWindowKeyAction.Process); } curPos--; word.Remove(curPos, 1); UpdateWordSelection(); return(ListWindowKeyAction.Process); case Key.Right: //if (curPos == word.Length) return KeyAction.CloseWindow | KeyAction.Process; //curPos++; return(ListWindowKeyAction.Process); case Key.CapsLock: case Key.NumLock: case Key.ScrollLock: return(ListWindowKeyAction.Ignore); case Key.Return: //HACK? case Key.ISO_Enter: //case Key.Key_3270_Enter: case Key.NumPadEnter: return((list.SelectionDisabled? ListWindowKeyAction.Process : (ListWindowKeyAction.Complete | ListWindowKeyAction.Ignore)) | ListWindowKeyAction.CloseWindow); case Key.Escape: return(ListWindowKeyAction.CloseWindow | ListWindowKeyAction.Ignore); case Key.Home: case Key.End: return(ListWindowKeyAction.CloseWindow | ListWindowKeyAction.Process); case Key.ControlLeft: case Key.ControlRight: case Key.AltLeft: case Key.AltRight: case Key.ShiftLeft: case Key.ShiftRight: case Key.ShiftLock: //TODO: Is this AltGr? //case Gdk.Key.ISO_Level3_Shift: // AltGr return(ListWindowKeyAction.Process); } return(ListWindowKeyAction.CloseWindow | ListWindowKeyAction.Process); }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (captureOperation != CaptureOperation.None) { if (captureOperation == CaptureOperation.ClickPattern) { if (GetPatternForCoord(e.X, e.Y, out int channelIdx, out int patternIdx)) { minSelectedChannelIdx = channelIdx; maxSelectedChannelIdx = channelIdx; minSelectedPatternIdx = patternIdx; maxSelectedPatternIdx = patternIdx; ConditionalInvalidate(); } else { ClearSelection(); } } else if (captureOperation == CaptureOperation.DragSelection) { bool copy = ModifierKeys.HasFlag(Keys.Control); int centerX = e.X - selectionDragAnchorX + patternSizeX / 2; int basePatternIdx = (centerX - trackNameSizeX + scrollX) / patternSizeX; Pattern[,] tmpPatterns = new Pattern[maxSelectedChannelIdx - minSelectedChannelIdx + 1, maxSelectedPatternIdx - minSelectedPatternIdx + 1]; App.UndoRedoManager.BeginTransaction(TransactionScope.Song, Song.Id); for (int i = minSelectedChannelIdx; i <= maxSelectedChannelIdx; i++) { for (int j = minSelectedPatternIdx; j <= maxSelectedPatternIdx; j++) { tmpPatterns[i - minSelectedChannelIdx, j - minSelectedPatternIdx] = Song.Channels[i].PatternInstances[j]; if (!copy) { Song.Channels[i].PatternInstances[j] = null; } } } for (int i = minSelectedChannelIdx; i <= maxSelectedChannelIdx; i++) { for (int j = minSelectedPatternIdx; j <= maxSelectedPatternIdx; j++) { Song.Channels[i].PatternInstances[j + basePatternIdx - minSelectedPatternIdx] = tmpPatterns[i - minSelectedChannelIdx, j - minSelectedPatternIdx]; } } App.UndoRedoManager.EndTransaction(); ClearSelection(); ConditionalInvalidate(); } Capture = false; captureOperation = CaptureOperation.None; }
/// <summary> /// Occurs when the value of the <see cref="Modifiers"/> dependency property changes. /// </summary> private static void HandleModifiersChanged(DependencyObject dobj, ModifierKeys oldValue, ModifierKeys newValue) { var binding = (KeyBinding)dobj; binding.UpdateGestureFromBinding(); }
public bool OnHotkey(Keys keyData) { if (ModifierKeys.HasFlag(Keys.Control)) { var key = keyData & ~Keys.Control; switch (key) { case Keys.N: ClearAllPixelsButton.PerformClick(); return(true); case Keys.I: InverseButton.PerformClick(); return(true); case Keys.R: ResizeButton.PerformClick(); return(true); case Keys.C: CopyButton.PerformClick(); return(true); case Keys.V: PasteButton.PerformClick(); return(true); case Keys.A: ImageListBox.BeginUpdate(); ImageListBox.SelectedIndices.Clear(); ImageListBox.SelectedIndices.AddRange(Enumerable.Range(0, ImageListBox.Items.Count)); ImageListBox.EndUpdate(); return(true); case Keys.Up: ShiftUpButton.PerformClick(); return(true); case Keys.Down: ShiftDownButton.PerformClick(); return(true); case Keys.Left: ShiftLeftButton.PerformClick(); return(true); case Keys.Right: ShiftRightButton.PerformClick(); return(true); case Keys.Z: ImagePixelGrid.Undo(); return(true); } } if (ModifierKeys.HasFlag(Keys.Shift)) { var key = keyData & ~(Keys.Control | Keys.Shift); switch (key) { case Keys.Z: ImagePixelGrid.Redo(); return(true); } } return(false); }
/// <inheritdoc/> public override Boolean MatchesKeyDown(KeyboardDevice device, Key key, ModifierKeys modifiers, RoutedEventData data) => IsValid(data.Source) ? WrappedGesture.MatchesKeyDown(device, key, modifiers, data) : false;
/// <summary> /// Called on MouseMove event raised from Map Control when tool is activated. /// </summary> public void OnMouseMove(MouseButtonState left, MouseButtonState right, MouseButtonState middle, ModifierKeys modifierKeys, double x, double y) { }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); ControlActivated?.Invoke(); bool left = e.Button.HasFlag(MouseButtons.Left); bool middle = e.Button.HasFlag(MouseButtons.Middle) || (e.Button.HasFlag(MouseButtons.Left) && ModifierKeys.HasFlag(Keys.Alt)); bool right = e.Button.HasFlag(MouseButtons.Right); bool canCapture = captureOperation == CaptureOperation.None; CancelDragSelection(); UpdateCursor(); if (middle) { mouseLastX = e.X; mouseLastY = e.Y; Capture = true; return; } // Track muting, soloing. else if ((left || right) && e.X < trackNameSizeX) { var trackIcon = GetTrackIconForPos(e); var ghostIcon = GetTrackGhostForPos(e); if (trackIcon >= 0) { int bit = (1 << trackIcon); if (left) { // Toggle muted App.ChannelMask ^= bit; } else { // Toggle Solo if (App.ChannelMask == bit) { App.ChannelMask = 0xff; } else { App.ChannelMask = bit; } } ConditionalInvalidate(); return; } else if (ghostIcon >= 0) { App.GhostChannelMask ^= (1 << ghostIcon); ConditionalInvalidate(); return; } } if (IsMouseInHeader(e)) { if (left) { int frame = (int)Math.Round((e.X - trackNameSizeX + scrollX) / (float)patternSizeX * Song.PatternLength); App.Seek(frame); } else if (right && canCapture) { StartCaptureOperation(e, CaptureOperation.Select); UpdateSelection(e.X, true); } } else if (e.Y > headerSizeY && (left || right)) { if (e.Y > headerSizeY) { var newChannel = Utils.Clamp((e.Y - headerSizeY) / trackSizeY, 0, Song.Channels.Length - 1); if (newChannel != selectedChannel) { selectedChannel = newChannel; SelectedChannelChanged?.Invoke(selectedChannel); ConditionalInvalidate(); } } } bool inPatternZone = GetPatternForCoord(e.X, e.Y, out int channelIdx, out int patternIdx); if (inPatternZone) { var channel = Song.Channels[channelIdx]; var pattern = channel.PatternInstances[patternIdx]; if (left) { bool shift = ModifierKeys.HasFlag(Keys.Shift); if (pattern == null && !shift) { App.UndoRedoManager.BeginTransaction(TransactionScope.Song, Song.Id); channel.PatternInstances[patternIdx] = channel.CreatePattern(); PatternClicked?.Invoke(channelIdx, patternIdx); App.UndoRedoManager.EndTransaction(); ClearSelection(); ConditionalInvalidate(); } else if (canCapture) { if (pattern != null) { PatternClicked?.Invoke(channelIdx, patternIdx); } if (shift && minSelectedChannelIdx >= 0 && minSelectedPatternIdx >= 0) { if (channelIdx < minSelectedChannelIdx) { maxSelectedChannelIdx = minSelectedChannelIdx; minSelectedChannelIdx = channelIdx; } else { maxSelectedChannelIdx = channelIdx; } if (patternIdx < minSelectedPatternIdx) { maxSelectedPatternIdx = minSelectedPatternIdx; minSelectedPatternIdx = patternIdx; } else { maxSelectedPatternIdx = patternIdx; } return; } else if (!IsPatternSelected(channelIdx, patternIdx) && pattern != null) { minSelectedChannelIdx = channelIdx; maxSelectedChannelIdx = channelIdx; minSelectedPatternIdx = patternIdx; maxSelectedPatternIdx = patternIdx; } selectionDragAnchorX = e.X - trackNameSizeX + scrollX - minSelectedPatternIdx * patternSizeX; StartCaptureOperation(e, CaptureOperation.ClickPattern); ConditionalInvalidate(); } } else if (right && pattern != null) { App.UndoRedoManager.BeginTransaction(TransactionScope.Song, Song.Id); channel.PatternInstances[patternIdx] = null; App.UndoRedoManager.EndTransaction(); ClearSelection(); ConditionalInvalidate(); } } }
/// <summary> /// Recursively find and update every ICountdown control /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UpdateICountdowns(object sender, EventArgs e) { if (LastInvisibileInputTextUpdateTime != default && (DateTime.Now - LastInvisibileInputTextUpdateTime).TotalSeconds > 2.0) { InvisibleInputText = ""; LastInvisibileInputTextUpdateTime = default; } int modifierCount = 0; if (ModifierKeys.HasFlag(Keys.Control)) { modifierCount++; } if (ModifierKeys.HasFlag(Keys.Shift)) { modifierCount++; } if (ModifierKeys.HasFlag(Keys.Alt)) { modifierCount++; } if (modifierCount > 0) { if (translucencyEnabled) { if (Bounds.Contains(MousePosition) || modifierCount >= 2) { TempOverrideTranslucencyMode(); } else { StopTempOverrideTranslucencyMode(); } } else { TempOverrideTranslucencyMode(); } } else { StopTempOverrideTranslucencyMode(); } //Update ICountdowns recursiveUpdate(this); //Recursively updates every ICountdown control in the given control /* local */ void recursiveUpdate(Control c) { if (c is ICountdown ic) { ic.OnCountdownTick(Globals.PrimaryTimer.TimeLeft, Globals.SecondaryTimer.TimeLeft, Globals.PrimaryTimer.Overtime); } foreach (Control i in c.Controls) { recursiveUpdate(i); } } }
/// <summary> /// /// </summary> /// <param name="key"></param> /// <param name="modifier"></param> public HotKey(Key key, ModifierKeys modifier) { Key = key; Modifier = modifier; }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> public Shortcut(Key key) : this() { Key = key; Modifier = ModifierKeys.None; }
/// <summary> /// Called on Mouse double click event raised from Map Control when tool is activated. /// </summary> public void OnDblClick(ModifierKeys modifierKeys, double x, double y) { throw new NotImplementedException(); }
void DgFamilies_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0 && e.ColumnIndex >= 0) { string famID = (string)dgFamilies.CurrentRow.Cells["FamilyID"].Value; Family fam = ft.GetFamily(famID); if (fam != null) { if ((reportType == ReportType.MismatchedChildrenStatus || reportType == ReportType.MissingChildrenStatus) && ModifierKeys.Equals(Keys.Shift)) { List <IDisplayColourCensus> list = fam.Members.ToList <IDisplayColourCensus>(); ColourCensus rs = new ColourCensus(Countries.UNITED_KINGDOM, list); MainForm.DisposeDuplicateForms(rs); rs.Show(); rs.Focus(); } else { Facts factForm = new Facts(fam); MainForm.DisposeDuplicateForms(factForm); factForm.Show(); } } } }
public MouseWheel() { Keys = ModifierKeys.None; Direction = MouseWheelDirection.Down; }
/// <summary> /// Creates an HotKey object. This instance has to be registered in an HotKeyHost. /// </summary> /// <param name="key">The key</param> /// <param name="modifiers">The modifier. Multiple modifiers can be combined with or.</param> /// <param name="enabled">Specifies whether the HotKey will be enabled when registered to an HotKeyHost</param> public HotKey(Key key, ModifierKeys modifiers, bool enabled) { Key = key; Modifiers = modifiers; Enabled = enabled; }
private void comboBoxCustomEditProg_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxCustomEditProg.Enabled) { string progname = comboBoxCustomEditProg.Text.Replace(" (Ext)", ""); // remove the EXT marker ActionProgram p = null; if (!progname.Equals("New")) { p = actionfile.actionprogramlist.Get(progname); } if (p != null && p.StoredInSubFile != null) { p.EditInEditor(p.StoredInSubFile); // Edit in the editor.. } else { ActionProgramEditForm apf = new ActionProgramEditForm(); apf.EditProgram += EditProgram; apf.Init("Action program ", this.Icon, actioncorecontroller, applicationfolder, onAdditionalNames(""), actionfile.name, p, actionfile.actionprogramlist.GetActionProgramList(), "", ModifierKeys.HasFlag(Keys.Shift)); DialogResult res = apf.ShowDialog(); if (res == DialogResult.OK) { ActionProgram np = apf.GetProgram(); actionfile.actionprogramlist.AddOrChange(np); // replaces or adds (if its a new name) same as rename Usercontrol_RefreshEvent(); } else if (res == DialogResult.Abort) // delete { ActionProgram np2 = apf.GetProgram(); actionfile.actionprogramlist.Delete(np2.Name); Usercontrol_RefreshEvent(); } } } }
private void Progedit_Click(object sender, EventArgs e) { bool shift = ModifierKeys.HasFlag(Keys.Shift); ActionProgram p = null; if (proglist.SelectedIndex > 0) // exclude NEW from checking for program { p = actionfile.actionprogramlist.Get(proglist.Text); } if (p != null && p.StoredInSubFile != null && shift) // if we have a stored in sub file, but we shift hit, cancel it { if (ExtendedControls.MessageBoxTheme.Show(this, "Do you want to bring the file back into the main file", "WARNING", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { p.CancelSubFileStorage(); shift = false; } else { return; // cancel, abort. } } if (p != null && p.StoredInSubFile != null) { p.EditInEditor(p.StoredInSubFile); // Edit in the editor.. this also updated the program steps held internally } else { string suggestedname = null; if (p == null) // if no program, create a new suggested name and clear any action data { suggestedname = eventtype.Text; int n = 2; while (actionfile.actionprogramlist.GetActionProgramList().Contains(suggestedname)) { suggestedname = eventtype.Text + "_" + n.ToString(System.Globalization.CultureInfo.InvariantCulture); n++; } paras.Text = ""; } ActionProgramEditForm apf = new ActionProgramEditForm(); apf.EditProgram += EditProgram; // we init with a variable list based on the field names of the group (normally the event field names got by SetFieldNames) // pass in the program if found, and its action data. apf.Init("Action program ", this.Icon, actioncorecontroller, applicationfolder, onAdditionalNames(eventtype.Text), actionfile.name, p, actionfile.actionprogramlist.GetActionProgramList(), suggestedname, ModifierKeys.HasFlag(Keys.Shift)); DialogResult res = apf.ShowDialog(); if (res == DialogResult.OK) { ActionProgram np = apf.GetProgram(); actionfile.actionprogramlist.AddOrChange(np); // replaces or adds (if its a new name) same as rename cd.action = np.Name; RefreshIt(); proglist.Enabled = false; proglist.SelectedItem = np.Name; proglist.Enabled = true; } else if (res == DialogResult.Abort) // delete { ActionProgram np2 = apf.GetProgram(); actionfile.actionprogramlist.Delete(np2.Name); cd.action = ""; RefreshIt(); } } }
private bool GetModifier(ModifierKeys key) { return((_Modifier & key) == key); }
VimKeyModifiers IKeyUtil.GetKeyModifiers(ModifierKeys modifierKeys) { return(ConvertToKeyModifiers(modifierKeys)); }