public override void OnKeyDown(IKeyEventArgs e) { double distance = 5; if ((e.KeyModifiers & KeyModifiers.Shift) == KeyModifiers.Shift) { distance = 50; } if (e.Key == Key.Left) { Scene.PanView(-distance, 0); e.Handled = true; } else if (e.Key == Key.Right) { Scene.PanView(distance, 0); e.Handled = true; } else if (e.Key == Key.Up) { Scene.PanView(0, distance); e.Handled = true; } else if (e.Key == Key.Down) { Scene.PanView(0, -distance); e.Handled = true; } }
internal SelectionResult TrySelect(KeyEvent eventType, IKeyEventArgs args) { // to handle A+B+C(B is down in Chord) var downInChord = false; var type = eventType; var candidateNode = _treeWalker.GetChildOrNull((ICombination acc, ICombination combination) => { // mark down_in_chord and continue try to find trigger if (type == KeyEvent.Down && combination.Chord.Contains(args.KeyCode)) { downInChord = true; } if (args.KeyCode != combination.TriggerKey || combination.Disabled) { return(acc); } var mach = combination.Chord.All(args.KeyboardState.IsDown); if (!mach) { return(acc); } if (acc == null) { return(combination); } return(acc.ChordLength >= combination.ChordLength ? acc : combination); }); return(new SelectionResult(this, candidateNode, downInChord)); }
internal KeyPressEventArgsExt(char keyChar, IKeyEventArgs arg, int timestamp) : base(keyChar) { IsNonChar = keyChar == (char)0x0; Timestamp = timestamp; EventArgs = arg; }
public IEventResult OnKeyUp(IKeyEventArgs e) { if (_currentCmd != null) { _currentCmd.OnKeyUp(e); } return(null); }
public override IEventResult OnKeyDown(IKeyEventArgs e) { if (e.IsEscape) { _mgr.CancelCurrentCommand(); } return(EventResult.Handled); }
/// <summary> /// down up happened successively /// </summary> private IKeyCommand Hit(IHotkey hotkey, Action <IKeyEventArgs> execute, Predicate <IKeyEventArgs> canExecute = null, string description = "", string stateTree = KeyStateTrees.Default) { var noEventTimer = new NoEventTimer(); // state var handling = false; IKeyEventArgs keyDownEvent = null; void Reset() { handling = false; keyDownEvent = null; } var token = new KeyCommandTokens { hotkey.OnDown(e => { handling = true; keyDownEvent = e; }, e => { var noEventDuration = noEventTimer.NoEventDuration; if (noEventDuration > StateResetTime) { Reset(); } noEventTimer.EventPulse(); return(canExecute?.Invoke(e) ?? true); }, description, stateTree), hotkey.OnUp(e => { if (!handling) { Console.WriteLine($"\t{hotkey}_Hit Down CanExecute:false"); return; } handling = false; if (keyDownEvent == e.LastKeyDownEvent) { execute(e); } else { Console.WriteLine($"\t{hotkey}_Hit: last down event is not from me, Not Execute!"); } }, canExecute, description, stateTree) }; return(token); }
public void InvokeKeyDown(IKeyEventArgs e) { var handler = KeyDown; if (handler == null || e.Handled || !e.IsKeyDown) { return; } handler(this, e); }
public override IEventResult OnKeyDown(IKeyEventArgs e) { if (e.IsEscape) { presenter.RemoveEntity(_entityCopy); _mgr.CancelCurrentCommand(); } return(EventResult.Handled); }
public void OnEvent(IKeyEventArgs arg) { if (_semaphore == null) { return; } _eventArgsExt = arg; _semaphore.Release(); }
/// <summary> /// if timeout return null /// </summary> public async Task <IKeyEventArgs> WaitAsync(int timeout = -1) { _eventArgsExt = null; if (_semaphore == null) { _semaphore = new SemaphoreSlim(0); } await _semaphore.WaitAsync(timeout); return(_eventArgsExt); }
public static void HostInputOnKeyDown(IKeyEventArgs args, IRenderHost renderHost) { switch (args.Modifiers) { case Modifiers.Control when args.Key == Key.F12: SeedProjectionTransition.Switch(renderHost); break; case Modifiers.None when args.Key == Key.F12: SeedProjectionTransition.Transit(renderHost); break; } }
public void InvokeKeyDown(IKeyEventArgs e) { var handler = KeyDown; if (DisableDownEvent) { _logger.LogDebug("this KeyUp event disabled"); return; } if (handler == null || !e.IsKeyDown || e.Handled) { return; } handler(this, e); }
public void InvokeKeyUp(IKeyEventArgs e) { var handler = KeyUp; if (handler == null || e.Handled || !e.IsKeyUp) { return; } if (KeyboardState.HandledDownKeys.IsDown(e.KeyCode)) { KeyboardState.HandledDownKeys.SetKeyUp(e.KeyCode); } handler(this, e); }
public override IEventResult OnKeyDown(IKeyEventArgs e) { if (e.IsEscape) { if (_xlines.Count > 0) { _mgr.FinishCurrentCommand(); } else { _mgr.CancelCurrentCommand(); } } return(EventResult.Handled); }
public IEventResult OnKeyDown(IKeyEventArgs e) { if (_currentCmd != null) { var eRet = _currentCmd.OnKeyDown(e); if (eRet != null && eRet.status == EventResultStatus.Unhandled) { if (e.IsEscape) { this.CancelCurrentCommand(); } } } return(EventResult.Handled); }
public override IEventResult OnKeyDown(IKeyEventArgs e) { if (e.IsEscape) { if (_polyline.NumberOfVertices > 1) { _polyline.LayerId = this.document.currentLayerId; _polyline.Color = this.document.currentColor; _mgr.FinishCurrentCommand(); } else { _mgr.CancelCurrentCommand(); } } return(EventResult.Handled); }
public override IEventResult OnKeyDown(IKeyEventArgs e) { if (e.IsEscape) { //if (_step == Step.Step3_SpecifySecondPoint) //{ if (_actions.Count > 0) { _mgr.FinishCurrentCommand(); } else { _mgr.CancelCurrentCommand(); } //} } return(EventResult.Handled); }
public void InvokeKeyUp(IKeyEventArgs e) { var handler = KeyUp; if (handler == null || !e.IsKeyUp || e.Handled) { return; } if (KeyboardState.HandledDownKeys.IsDown(e.KeyCode)) { KeyboardState.HandledDownKeys.SetKeyUp(e.KeyCode); } if (DisableUpEvent) { _logger.LogDebug("this KeyUp event disabled"); return; } handler(this, e); }
/// <summary> /// down up happened successively /// </summary> internal IKey Hit(ICombination combination, Action <IKeyEventArgs> execute, Predicate <IKeyEventArgs> canExecute = null, string description = "", string stateTree = KeyStateTrees.Default) { var handling = false; IKeyEventArgs keyDownEvent = null; var token = new KeyTokens { combination.Down(e => { handling = true; keyDownEvent = e; }, canExecute, description, stateTree), combination.Up(e => { if (!handling) { Console.WriteLine($"\t{combination}_Hit Down CanExecute:false"); return; } handling = false; if (keyDownEvent == e.LastKeyDownEvent) { e.BeginInvoke(() => execute(e)); } else { Console.WriteLine($"\t{combination}_Hit: last down event is not from me, Not Execute!"); } }, canExecute, description, stateTree) }; return(token); }
public IEventResult OnKeyUp(IKeyEventArgs KeyEventArgs) { return(null); }
public override IEventResult OnKeyUp(IKeyEventArgs e) { return(EventResult.Handled); }
private static void InputOneKeyDown(object sender, IKeyEventArgs args) { Console.WriteLine($"{nameof(IInput.KeyDown)} {args.Key}, Modifier Key:{args.Modifiers}"); }
/// <inheritdoc cref="IInput.KeyUp"/> protected virtual void InputOnKeyUp(object sender, IKeyEventArgs args) { }
protected override IEnumerable <KeyPressEventArgsExt> GetPressEventArgs(CallbackData data, IKeyEventArgs arg) { return(KeyPressEventArgsExt.FromRawDataApp(data, arg)); }
internal static IEnumerable <KeyPressEventArgsExt> FromRawDataGlobal(CallbackData data, IKeyEventArgs arg) { var wParam = data.WParam; var lParam = data.LParam; if ((int)wParam != Messages.WM_KEYDOWN && (int)wParam != Messages.WM_SYSKEYDOWN) { yield break; } var keyboardHookStruct = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct)); var virtualKeyCode = keyboardHookStruct.VirtualKeyCode; var scanCode = keyboardHookStruct.ScanCode; var fuState = keyboardHookStruct.Flags; if (virtualKeyCode == KeyboardNativeMethods.VK_PACKET) { var ch = (char)scanCode; yield return(new KeyPressEventArgsExt(ch, arg, keyboardHookStruct.Time)); } else { char[] chars; KeyboardNativeMethods.TryGetCharFromKeyboardState(virtualKeyCode, scanCode, fuState, out chars); if (chars == null) { yield break; } foreach (var current in chars) { yield return(new KeyPressEventArgsExt(current, arg, keyboardHookStruct.Time)); } } }
/// <summary> /// Initializes a new instance of the <see cref='KeyPressEventArgsExt' /> class. /// </summary> /// <param name="keyChar"> /// Character corresponding to the key pressed. 0 char if represents a system or functional non char /// key. /// </param> public KeyPressEventArgsExt(char keyChar, IKeyEventArgs arg) : this(keyChar, arg, Environment.TickCount) { }
public virtual void OnKeyDown(IKeyEventArgs e) { }
private static void Desktop_KeyDown(object sender, IKeyEventArgs e) { //Desktop.Text += e.KeyCode.ToString(); }
internal static IEnumerable <KeyPressEventArgsExt> FromRawDataApp(CallbackData data, IKeyEventArgs arg) { var wParam = data.WParam; var lParam = data.LParam; //http://msdn.microsoft.com/en-us/library/ms644984(v=VS.85).aspx const uint maskKeydown = 0x40000000; // for bit 30 const uint maskKeyup = 0x80000000; // for bit 31 const uint maskScanCode = 0xff0000; // for bit 23-16 var flags = (uint)lParam.ToInt64(); //bit 30 Specifies the previous key state. The value is 1 if the key is down before the message is sent; it is 0 if the key is up. var wasKeyDown = (flags & maskKeydown) > 0; //bit 31 Specifies the transition state. The value is 0 if the key is being pressed and 1 if it is being released. var isKeyReleased = (flags & maskKeyup) > 0; if (!wasKeyDown && !isKeyReleased) { yield break; } var virtualKeyCode = (int)wParam; var scanCode = checked ((int)(flags & maskScanCode)); const int fuState = 0; char[] chars; KeyboardNativeMethods.TryGetCharFromKeyboardState(virtualKeyCode, scanCode, fuState, out chars); if (chars == null) { yield break; } foreach (var ch in chars) { yield return(new KeyPressEventArgsExt(ch, arg)); } }
public virtual void OnKeyUp(IKeyEventArgs e) { }