private void Period_Tap( object sender, SysWinInput.GestureEventArgs e ) { var period = (Period) ( (FrameworkElement) sender ).DataContext; var converter = (EnumToLocalizedStringConverter) Resources["EnumToString"]; string typeString = (string) converter.Convert( period.PeriodType, null, null, null ); string text = typeString + Environment.NewLine + string.Join( ", ", period.Rooms ); MessageBox.Show( text, period.CourseName, MessageBoxButton.OK ); Messenger.Send( new EventLogRequest( "ViewPeriodProperties", period.CourseName ) ); }
/// <summary> /// Responds to key presses inside a wpf window /// </summary> void Window_MouseMove(object sender, WindowsInput.MouseEventArgs e) { //_logger.Debug("Window_MouseMove"); if (_mouseMove != null) { _mouseMove.Invoke(null, e); } }
/// <summary> /// Responds to key presses inside a wpf window /// </summary> void Window_KeyDown(object sender, WindowsInput.KeyEventArgs e) { _logger.Debug("Window_KeyDown {0}", e.Key); if (_keyDown != null) { _keyDown.Invoke(null, e); } }
private bool IsMediaCommand(WindowsInput.Key key) { return key == Key.MediaNextTrack || key == Key.MediaPreviousTrack || key == Key.MediaStop || key == Key.MediaPlayPause; }
/// <summary> /// Responds to key down in application /// </summary> void input_KeyDown(object sender, WindowsInput.KeyEventArgs e) { _logger.Debug("input_KeyDown {0} Ctrl({1}) Shift({2})", e.Key, IsControlKeyDown(), IsShiftKeyDown()); if (IsDuplicateMediaKeyEvent(e.Key)) { _logger.Debug("KeyDown IsDuplicateMediaKeyEvent true:- Key {0} after cmd {1}", e.Key, _lastCmd); } else { var command = _inputCommandMaps.GetMappedCommand(e.Key, IsControlKeyDown(), IsShiftKeyDown()); SendCommandEvents(command, null); } _lastKeyDown = e.Key; _lastKeyDownTime = DateTime.Now; }
private bool IsDuplicateMediaKeyEvent(WindowsInput.Key key) { return IsMediaCommand(key) && MatchCommandWithWindowsKey(key); }
static Keys GetKeyConversion(SWI.Key slKey) { Debug.Assert((int)slKey < 256); return SilverlightToXna[(int)slKey]; }
public static MouseEventArgs ToEto(this swi.MouseEventArgs e, sw.IInputElement control, swi.MouseButtonState buttonState = swi.MouseButtonState.Pressed) { var buttons = MouseButtons.None; if (e.LeftButton == buttonState) buttons |= MouseButtons.Primary; if (e.RightButton == buttonState) buttons |= MouseButtons.Alternate; if (e.MiddleButton == buttonState) buttons |= MouseButtons.Middle; var modifiers = Key.None; var location = e.GetPosition(control).ToEto(); return new MouseEventArgs(buttons, modifiers, location); }
public void OnMouseUp(Vector2 pos, SysInput.MouseButtonEventArgs e) { MouseUp(this, new MouseButtonEventArgs() { Pos = pos, Args = e }); }
public void OnMouseWheel(SysInput.MouseWheelEventArgs e) { MouseWheel(this, new MouseWheelEventArgs() { Args = e }); }
/// <summary> /// Handler for the KeyDown event of the textBoxPeriod, textBoxTimeDomain controls. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">Event data.</param> private void _NumericTextBoxKeyDown(object sender, WinInput.KeyEventArgs e) { // determine whether the keystroke is a number from the keypad. bool isNumPadNumeric = ((WinInput.Key.NumPad0 <= e.Key) && (e.Key <= WinInput.Key.NumPad9)); // determine whether the keystroke is a number from the top of the keyboard. bool isNumeric = ((WinInput.Key.D0 <= e.Key) && (e.Key <= WinInput.Key.D9)); // ignore all not numeric keys or Tab e.Handled = (!isNumeric && !isNumPadNumeric && (e.Key != WinInput.Key.Tab)); }
public static MouseEventArgs ConvertMouseEvent (sw.IInputElement control, swi.MouseEventArgs e) { var buttons = MouseButtons.None; if (e.LeftButton == swi.MouseButtonState.Pressed) buttons |= MouseButtons.Primary; if (e.RightButton == swi.MouseButtonState.Pressed) buttons |= MouseButtons.Alternate; if (e.MiddleButton == swi.MouseButtonState.Pressed) buttons |= MouseButtons.Middle; var modifiers = Key.None; var location = Generator.Convert(e.GetPosition(control)); return new MouseEventArgs(buttons, modifiers, location); }
public static KeyPressEventArgs Convert (swi.KeyEventArgs e) { var key = KeyMap.Convert (e.Key, swi.Keyboard.Modifiers); return new KeyPressEventArgs (key) { Handled = e.Handled }; }
// <summary> // Send a Key to currently active element, // 1. the element will in receive a KeyDown event which will // 2. The elemen will implement the actions - i.e move // 3. The Keydown will be picked up by the input manager and the generate a Command matching the key // see http://stackoverflow.com/questions/1645815/how-can-i-programmatically-generate-keypress-events-in-c // </summary> public void SendKeyEventToFocusedElement(WindowsInput.Key key, RoutedEvent keyUpOrKeyDownEvent) { _logger.Debug("SendKeyEventToFocusedElement {0} {1}", keyUpOrKeyDownEvent, key); if (keyUpOrKeyDownEvent != Keyboard.KeyDownEvent && keyUpOrKeyDownEvent != Keyboard.KeyUpEvent) { throw new ArgumentException(String.Format("SendKeyEventToFocusedElement: Invlaid Argument {0}. Only Keyboard.KeyDownEvent or Keyboard.KeyUpEvent is valid", keyUpOrKeyDownEvent)); } _presentationManager.Window.Dispatcher.Invoke(() => { // _presentation.EnsureApplicationWindowHasFocus(); // need this when testing and running on the same display and input, proably not in prod env var source = (HwndSource)PresentationSource.FromVisual(_presentationManager.Window); var keyEventArgs = new KeyEventArgs ( Keyboard.PrimaryDevice, source, 0, key ) { RoutedEvent = keyUpOrKeyDownEvent }; InputManager.Current.ProcessInput(keyEventArgs); }); }
// <summary> // Send a KeyUp to currently active element, // </summary> public void SendKeyUpEventToFocusedElement(WindowsInput.Key key) { SendKeyEventToFocusedElement(key, Keyboard.KeyUpEvent); }
/// <summary> /// Route a KeyDown event via the input Manager /// </summary> public void OnKeyDown(WindowsInput.KeyEventArgs e) { _logger.Debug("OnKeyDown {0}", e.Key); Window_KeyDown(null, e); }
/// <summary> /// Route a KeyDown event via the input Manager /// </summary> public void OnMouseMove(WindowsInput.MouseEventArgs e) { //_logger.Debug("OnMouseMove {0}"); Window_MouseMove(null, e); }
private bool MatchCommandWithWindowsKey(WindowsInput.Key key) { if ((_lastCmd == AppCommand.APPCOMMAND_MEDIA_NEXTTRACK && key == Key.MediaNextTrack) || (_lastCmd == AppCommand.APPCOMMAND_MEDIA_PREVIOUSTRACK && key == Key.MediaPreviousTrack) || (_lastCmd == AppCommand.APPCOMMAND_MEDIA_STOP && key == Key.MediaStop) || (_lastCmd == AppCommand.APPCOMMAND_MEDIA_PLAY_PAUSE && key == Key.MediaPlayPause)) { // its the same command, did it occur in the last DuplicateCommandPeriod Milliseconds TimeSpan span = DateTime.Now - _lastCmdTime; return span.TotalMilliseconds < DuplicateCommandPeriod; } else { return false; } }
public static MouseEventArgs ToEto(this swi.MouseWheelEventArgs e, sw.IInputElement control, swi.MouseButtonState buttonState = swi.MouseButtonState.Pressed) { var buttons = MouseButtons.None; if (e.LeftButton == buttonState) buttons |= MouseButtons.Primary; if (e.RightButton == buttonState) buttons |= MouseButtons.Alternate; if (e.MiddleButton == buttonState) buttons |= MouseButtons.Middle; var modifiers = Key.None; var location = e.GetPosition(control).ToEto(); var delta = new SizeF(0, (float)e.Delta / WHEEL_DELTA); return new MouseEventArgs(buttons, modifiers, location, delta); }
static void SetKeyConversion(SWI.Key slKey, Keys xnaKey) { Debug.Assert((int)slKey < 256); SilverlightToXna[(int)slKey] = xnaKey; }