private void OnActivity(object sender, PreProcessInputEventArgs e) { InputEventArgs inputEventArgs = e.StagingItem.Input; if (inputEventArgs is MouseEventArgs || inputEventArgs is KeyboardEventArgs) { if (e.StagingItem.Input is MouseEventArgs mouseEventArgs) { // no button is pressed and the position is still the same as the application became inactive if (mouseEventArgs.LeftButton == MouseButtonState.Released && mouseEventArgs.RightButton == MouseButtonState.Released && mouseEventArgs.MiddleButton == MouseButtonState.Released && mouseEventArgs.XButton1 == MouseButtonState.Released && mouseEventArgs.XButton2 == MouseButtonState.Released && _inactiveMousePosition == mouseEventArgs.GetPosition(MediaPlayerGrid)) { return; } } // set UI on activity Cursor = _tempCursor; if (showAnimation) { (FindResource("Show") as Storyboard).Begin(Statusbar); showAnimation = false; } //Statusbar.Visibility = Visibility.Visible; _activityTimer.Stop(); _activityTimer.Start(); } }
void OnActivity(object sender, PreProcessInputEventArgs e) { InputEventArgs inputEventArgs = e.StagingItem.Input; if (inputEventArgs is MouseEventArgs || inputEventArgs is KeyboardEventArgs) { if (e.StagingItem.Input is MouseEventArgs) { MouseEventArgs mouseEventArgs = (MouseEventArgs)e.StagingItem.Input; // no button is pressed and the position is still the same as the application became inactive if (mouseEventArgs.LeftButton == MouseButtonState.Released && mouseEventArgs.RightButton == MouseButtonState.Released && mouseEventArgs.MiddleButton == MouseButtonState.Released && mouseEventArgs.XButton1 == MouseButtonState.Released && mouseEventArgs.XButton2 == MouseButtonState.Released && _inactiveMousePosition == mouseEventArgs.GetPosition(this)) { return; } } /* * // set UI on activity * rectangle.Visibility = Visibility.Visible; */ _activityTimer.Stop(); _activityTimer.Start(); } }
private static void PreProcessKeyboardInput(object sender, PreProcessInputEventArgs e) { if (e.Input.Device == Keyboard.PrimaryDevice) { KeyEventArgs keyEventArgs = e.Input as KeyEventArgs; if (keyEventArgs != null) { string text = keyEventArgs.KeyboardDevice.KeyToString(keyEventArgs.Key); if (text != string.Empty && !char.IsControl(text[0])) { TextComposition composition = new TextComposition( InputManager.Current, keyEventArgs.Device.Target, text); TextCompositionEventArgs ev = new TextCompositionEventArgs( keyEventArgs.Device, composition); ev.RoutedEvent = TextInputEvent; InputManager.Current.ProcessInput(ev); } } } }
private void InputDeviceEvents_PreProcessInput(object sender, PreProcessInputEventArgs e) { if (e.StagingItem.Input.Device is TouchDevice) { InputReportEventArgs irea = e.StagingItem.Input as InputReportEventArgs; if (irea != null) { RawTouchInputReport rtir = irea.Report as RawTouchInputReport; if (rtir != null) { // cancel any touch event that does not start within the modal window //if (!this.ContainsPoint(rtir.Touches[0].X, rtir.Touches[0].Y)) // e.Cancel(); int x = rtir.Touches[0].X; int y = rtir.Touches[0].Y; PointToClient(ref x, ref y); if (!Utils.IsWithinRectangle(x, y, ActualWidth, ActualWidth)) { e.Cancel(); } } } } }
void OnActivity(object sender, PreProcessInputEventArgs e) { InputEventArgs inputEventArgs = e.StagingItem.Input; if (inputEventArgs is MouseEventArgs || inputEventArgs is KeyboardEventArgs) { if (e.StagingItem.Input is MouseEventArgs) { MouseEventArgs mouseEventArgs = (MouseEventArgs)e.StagingItem.Input; // no button is pressed and the position is still the same as the application became inactive if (mouseEventArgs.LeftButton == MouseButtonState.Released && mouseEventArgs.RightButton == MouseButtonState.Released && mouseEventArgs.MiddleButton == MouseButtonState.Released && mouseEventArgs.XButton1 == MouseButtonState.Released && mouseEventArgs.XButton2 == MouseButtonState.Released && _inactiveMousePosition == mouseEventArgs.GetPosition(grdContainer)) { return; } } mIdle.Stop(); mIdle.Start(); } }
private void HandlePreProcessInput(object sender, PreProcessInputEventArgs e) { this.OnPropertyChanged("CurrentFocus"); ModifierKeys currentModifiers = InputManager.Current.PrimaryKeyboardDevice.Modifiers; if (!((currentModifiers & ModifierKeys.Control) != 0 && (currentModifiers & ModifierKeys.Shift) != 0)) { return; } //ModifierKeys currentModifiers = InputManager.Current.PrimaryKeyboardDevice.Modifiers; if ((currentModifiers & ModifierKeys.Alt) != 0) { return; } Visual directlyOver = Mouse.PrimaryDevice.DirectlyOver as Visual; if ((directlyOver == null) || directlyOver.IsDescendantOf(this)) { return; } VisualTreeItem node = this.FindItem(directlyOver); if (node != null) { this.CurrentSelection = node; } }
private static void OnPreProcessInput(object sender, PreProcessInputEventArgs e) { if (e.StagingItem.Input.Device != null) { e.Cancel(); } }
void OnActivity(object sender, PreProcessInputEventArgs e) { InputEventArgs inputEventArgs = e.StagingItem.Input; if (inputEventArgs is MouseEventArgs || inputEventArgs is KeyboardEventArgs) { if (e.StagingItem.Input is MouseEventArgs) { MouseEventArgs mouseEventArgs = (MouseEventArgs)e.StagingItem.Input; // no button is pressed and the position is still the same as the application became inactive if (isTest) { Trace.WriteLine($"Mouse Position={_inactiveMousePosition == mouseEventArgs.GetPosition(_inputElement)}"); } if (mouseEventArgs.LeftButton == MouseButtonState.Released && mouseEventArgs.RightButton == MouseButtonState.Released && mouseEventArgs.MiddleButton == MouseButtonState.Released && mouseEventArgs.XButton1 == MouseButtonState.Released && mouseEventArgs.XButton2 == MouseButtonState.Released && _inactiveMousePosition == mouseEventArgs.GetPosition(_inputElement)) { return; } } if (isTest) { Trace.WriteLine($"Idle reset={inputEventArgs.GetType()}"); } _activityTimer.Stop(); _activityTimer.Start(); } }
private void OnActivity(object sender, PreProcessInputEventArgs e) { if (_activityTimer == null || _mainWindow == null) { return; } var inputEventArgs = e.StagingItem.Input; if (inputEventArgs is MouseEventArgs || inputEventArgs is KeyboardEventArgs) { var mouseEventArgs = e.StagingItem.Input as MouseEventArgs; // no button is pressed and the position is still the same as the application became inactive if (mouseEventArgs?.LeftButton == MouseButtonState.Released && mouseEventArgs.RightButton == MouseButtonState.Released && mouseEventArgs.MiddleButton == MouseButtonState.Released && mouseEventArgs.XButton1 == MouseButtonState.Released && mouseEventArgs.XButton2 == MouseButtonState.Released && _inactiveMousePosition == mouseEventArgs.GetPosition(_mainWindow.MainGrid)) { return; } _activityTimer.Stop(); _activityTimer.Start(); } }
private void InputManager_PreProcessInput(object sender, PreProcessInputEventArgs e) { if (e.StagingItem.Input is MouseButtonEventArgs) { MouseButtonEventArgs clickEventArgs = (MouseButtonEventArgs)e.StagingItem.Input; if (clickEventArgs.ChangedButton == MouseButton.Left && clickEventArgs.LeftButton == MouseButtonState.Pressed) { if (IsEditing && !EditingTextBox.IsMouseOver) { EndEditing(); } } } else if (e.StagingItem.Input is KeyEventArgs) { KeyEventArgs keyEventArgs = (KeyEventArgs)e.StagingItem.Input; if (keyEventArgs.IsDown && keyEventArgs.Key == Key.Return) { if (IsEditing) { EndEditing(); } } } }
void Idle_PreProcessInput(object sender, PreProcessInputEventArgs e) { mIdle.IsEnabled = false; mIdle.Stop(); mIdle.IsEnabled = true; mIdle.Start(); }
void HandlePreProcessInput(object sender, PreProcessInputEventArgs e) { OnPropertyChanged("CurrentFocus"); var currentModifiers = InputManager.Current.PrimaryKeyboardDevice.Modifiers; if (!((currentModifiers & ModifierKeys.Control) != 0 && (currentModifiers & ModifierKeys.Shift) != 0)) { navigatingBetweenTree = false; return; } if (e.StagingItem.Input.RoutedEvent == Mouse.PreviewMouseWheelEvent) { navigatingBetweenTree = true; if (((MouseWheelEventArgs)e.StagingItem.Input).Delta > 0) { Tree.Items.MoveCurrentToPrevious(); } else { Tree.Items.MoveCurrentToNext(); } e.StagingItem.Input.Handled = true; return; } if (e.StagingItem.Input.RoutedEvent == Mouse.PreviewMouseDownEvent) { if (((MouseButtonEventArgs)e.StagingItem.Input).ChangedButton == MouseButton.Middle) { var vi = Tree.SelectedValue as VisualTreeItem; if (vi != null) { vi.IsExpanded = !vi.IsExpanded; } e.StagingItem.Input.Handled = true; return; } } if (navigatingBetweenTree) { return; } var directlyOver = Mouse.PrimaryDevice.Wrap <IMouseDevice>().RawDirectlyOver as Visual; if ((directlyOver == null) || directlyOver.IsDescendantOf(this)) { return; } var node = FindItem(directlyOver); if (node != null) { CurrentSelection = node; } }
private void Current_PreProcessInput(object sender, PreProcessInputEventArgs e) { SleepTime = DateTime.Now.AddSeconds(SecondsToPause); if (CameraListBox.SelectedIndex > -1 && mjpegstream != null && !mjpegstream.IsRunning && PreviewStreamErrorCount < 3) { StartMjpegStream(); } }
/// <summary> /// Show the PlayerStatusBar on mouse activity /// </summary> /// <param name="sender">Sender object</param> /// <param name="e">EventArgs</param> private async void OnActivity(object sender, PreProcessInputEventArgs e) { await MouseActivitySemaphore.WaitAsync(); if (e.StagingItem == null) { MouseActivitySemaphore.Release(); return; } var inputEventArgs = e.StagingItem.Input; if (!(inputEventArgs is MouseEventArgs) && !(inputEventArgs is KeyboardEventArgs)) { MouseActivitySemaphore.Release(); return; } var mouseEventArgs = e.StagingItem.Input as MouseEventArgs; // no button is pressed and the position is still the same as the application became inactive if (mouseEventArgs?.LeftButton == MouseButtonState.Released && mouseEventArgs.RightButton == MouseButtonState.Released && mouseEventArgs.MiddleButton == MouseButtonState.Released && mouseEventArgs.XButton1 == MouseButtonState.Released && mouseEventArgs.XButton2 == MouseButtonState.Released && InactiveMousePosition == mouseEventArgs.GetPosition(Container)) { MouseActivitySemaphore.Release(); return; } var opacityAnimation = new DoubleAnimationUsingKeyFrames { Duration = new Duration(TimeSpan.FromSeconds(0.1)), KeyFrames = new DoubleKeyFrameCollection { new EasingDoubleKeyFrame(1.0, KeyTime.FromPercent(1.0), new PowerEase { EasingMode = EasingMode.EaseInOut }) } }; PlayerStatusBar.BeginAnimation(OpacityProperty, opacityAnimation); UpperPanel.BeginAnimation(OpacityProperty, opacityAnimation); var window = System.Windows.Window.GetWindow(this); if (window != null) { window.Cursor = Cursors.Arrow; } await Task.Delay(TimeSpan.FromSeconds(1)); MouseActivitySemaphore.Release(); }
private void GlobalClickEventHandler(object sender, PreProcessInputEventArgs e) { if (e.StagingItem.Input is MouseButtonEventArgs) { if (!_isClosing) { Close(); } } }
void Activity(object sender, PreProcessInputEventArgs e) { // extend if you need: StylusEventArgs, TouchEventArgs etc. if (e.StagingItem.Input is MouseEventArgs || e.StagingItem.Input is KeyboardEventArgs) { rectangle1.Visibility = Visibility.Visible; activityTimer.Stop(); activityTimer.Start(); } }
private void InputPreProcessInput(object sender, PreProcessInputEventArgs e) { InputEventArgs inputEventArgs = e.StagingItem.Input; if (inputEventArgs is MouseEventArgs || inputEventArgs is KeyboardEventArgs) { // reset timer _activityTimer.Stop(); _activityTimer.Start(); } }
private static void Current_PreProcessInput(object sender, PreProcessInputEventArgs e) { RoutedEvent routedEvent = e.StagingItem.Input.RoutedEvent; if (routedEvent == Keyboard.PreviewKeyDownEvent) { KeyEventArgs keyArgs = (KeyEventArgs)e.StagingItem.Input; if (IsKeyTipKey(keyArgs)) // || keyArgs.Key == Key.Tab) { e.StagingItem.Input.Handled = true; } } }
} // proc OnIdle private void RestartIdleTimer(PreProcessInputEventArgs e) { if (idleActions.Count > 0) { var inputEvent = e.StagingItem.Input; if (inputEvent is MouseEventArgs || inputEvent is KeyboardEventArgs) { restartTime = Environment.TickCount; idleTimer.Stop(); idleTimer.Start(); } } } // proc RestartIdleTimer
/// <summary> /// Show the PlayerStatusBar on mouse activity /// </summary> /// <param name="sender">Sender object</param> /// <param name="e">EventArgs</param> private async void OnActivity(object sender, PreProcessInputEventArgs e) { if (_isMouseActivityCaptured) { return; } _isMouseActivityCaptured = true; var inputEventArgs = e.StagingItem.Input; if (!(inputEventArgs is MouseEventArgs) && !(inputEventArgs is KeyboardEventArgs)) { _isMouseActivityCaptured = false; return; } var mouseEventArgs = e.StagingItem.Input as MouseEventArgs; // no button is pressed and the position is still the same as the application became inactive if (mouseEventArgs?.LeftButton == MouseButtonState.Released && mouseEventArgs.RightButton == MouseButtonState.Released && mouseEventArgs.MiddleButton == MouseButtonState.Released && mouseEventArgs.XButton1 == MouseButtonState.Released && mouseEventArgs.XButton2 == MouseButtonState.Released && InactiveMousePosition == mouseEventArgs.GetPosition(Container)) { _isMouseActivityCaptured = false; return; } var opacityAnimation = new DoubleAnimationUsingKeyFrames { Duration = new Duration(TimeSpan.FromSeconds(0.1)), KeyFrames = new DoubleKeyFrameCollection { new EasingDoubleKeyFrame(1.0, KeyTime.FromPercent(1.0), new PowerEase { EasingMode = EasingMode.EaseInOut }) } }; PlayerStatusBar.BeginAnimation(OpacityProperty, opacityAnimation); await Task.Delay(TimeSpan.FromSeconds(1)); _isMouseActivityCaptured = false; }
/// <summary> /// Show the PlayerStatusBar on mouse activity /// </summary> /// <param name="sender">Sender object</param> /// <param name="e">EventArgs</param> private void OnActivity(object sender, PreProcessInputEventArgs e) { var inputEventArgs = e.StagingItem.Input; if (inputEventArgs is MouseEventArgs || inputEventArgs is KeyboardEventArgs) { if (e.StagingItem.Input is MouseEventArgs) { var mouseEventArgs = (MouseEventArgs)e.StagingItem.Input; // no button is pressed and the position is still the same as the application became inactive if (mouseEventArgs.LeftButton == MouseButtonState.Released && mouseEventArgs.RightButton == MouseButtonState.Released && mouseEventArgs.MiddleButton == MouseButtonState.Released && mouseEventArgs.XButton1 == MouseButtonState.Released && mouseEventArgs.XButton2 == MouseButtonState.Released && InactiveMousePosition == mouseEventArgs.GetPosition(Container)) { return; } } if (!PlayerStatusBar.Opacity.Equals(0.0)) { return; } var opacityAnimation = new DoubleAnimationUsingKeyFrames { Duration = new Duration(TimeSpan.FromSeconds(0.1)), KeyFrames = new DoubleKeyFrameCollection { new EasingDoubleKeyFrame(0.0, KeyTime.FromPercent(0)), new EasingDoubleKeyFrame(1.0, KeyTime.FromPercent(1.0), new PowerEase { EasingMode = EasingMode.EaseInOut }) } }; PlayerStatusBar.BeginAnimation(OpacityProperty, opacityAnimation); PlayerStatusBar.Visibility = Visibility.Visible; } }
void inputManager_PreProcessInput(object sender, PreProcessInputEventArgs e) { RoutedEvent routedEvent = e.StagingItem.Input.RoutedEvent; if (routedEvent == PreviewRawInputEvent) { RawMultitouchReport report = e.StagingItem.Input as RawMultitouchReport; if (report != null && !report.Handled) { switch (report.Context.Contact.State) { case ContactState.New: return; case ContactState.Removed: case ContactState.Moved: { Contact contact; if (!ContactsManager.ExistingContacts.TryGetValue(report.Context.Contact.Id, out contact)) { break; } report.UpdateFromPrevious(contact.InputArgs); return; } default: return; } report.Handled = true; } } else if (!MultitouchScreen.AllowNonContactEvents) { if (!IsContactEvent(routedEvent)) { e.StagingItem.Input.Handled = true; e.Cancel(); } } Debug.Assert(routedEvent != null, "routed event null"); }
void Current_PreProcessInput(object sender, PreProcessInputEventArgs e) { InputEventArgs inputEventArgs = e.StagingItem.Input; if (inputEventArgs is KeyboardEventArgs) { KeyEventArgs keyEventArgs = inputEventArgs as KeyEventArgs; if (keyEventArgs != null && keyEventArgs.IsDown) { if (keyEventArgs.Key == Key.Delete) { if (_plottingArea != null && _plottingArea.Visibility == System.Windows.Visibility.Visible && _plottingArea.SelectedIndex >= 0) { _plottingArea.RemoveSelectedPoint(); } } return; } } }
private void OnPreProcessInput(object sender, PreProcessInputEventArgs e) { KeyboardDevice keyboard = InputManager.Current.PrimaryKeyboardDevice; ModifierKeys currentModifiers = keyboard.Modifiers; if (!((currentModifiers & ModifierKeys.Control) != 0 && (currentModifiers & ModifierKeys.Shift) != 0)) { return; } Visual directlyOver = Mouse.PrimaryDevice.DirectlyOver as Visual; if ((directlyOver == null) || directlyOver.IsDescendantOf(_crackRootVisual)) { return; } ViewModel.SelectItem(directlyOver); }
private void Current_PreProcessInput(object sender, PreProcessInputEventArgs e) { RoutedEvent routedEvent = e.StagingItem.Input.RoutedEvent; if (routedEvent == Keyboard.PreviewKeyDownEvent) { KeyEventArgs keyArgs = (KeyEventArgs)e.StagingItem.Input; if (keyArgs.Key == Key.Escape) { _owner.IsOpen = false; e.Cancel(); } } //RoutedEvent routedEvent = e.StagingItem.Input.RoutedEvent; //if (routedEvent == Keyboard.PreviewKeyDownEvent) //{ // KeyEventArgs keyArgs = (KeyEventArgs)e.StagingItem.Input; // if (keyArgs.Key == Key.Up || keyArgs.Key == Key.Down) // { // // Creating a FocusNavigationDirection object and setting it to a // // local field that contains the direction selected. // FocusNavigationDirection focusDirection = keyArgs.Key == Key.Up ? FocusNavigationDirection.Up : FocusNavigationDirection.Down; // // MoveFocus takes a TraveralReqest as its argument. // TraversalRequest request = new TraversalRequest(focusDirection); // // Gets the element with keyboard focus. // UIElement elementWithFocus = Keyboard.FocusedElement as UIElement; // // Change keyboard focus. // if (elementWithFocus != null) // { // elementWithFocus.MoveFocus(request); // e.StagingItem.Input.Handled = true; // } // } //} }
private void InputDeviceEvents_PreProcessInput(object sender, PreProcessInputEventArgs e) { if (e.StagingItem.Input.Device is TouchDevice) { InputReportEventArgs irea = e.StagingItem.Input as InputReportEventArgs; if (irea != null) { RawTouchInputReport rtir = irea.Report as RawTouchInputReport; if (rtir != null) { int x = rtir.Touches[0].X; int y = rtir.Touches[0].Y; PointToClient(ref x, ref y); if (!Utils.IsWithinRectangle(x, y, ActualWidth, ActualWidth)) { e.Cancel(); } } } } }
private void Current_PreProcessInput(object sender, PreProcessInputEventArgs e) { RoutedEvent routedEvent = e.StagingItem.Input.RoutedEvent; if (routedEvent == Keyboard.PreviewKeyDownEvent) { KeyEventArgs keyArgs = (KeyEventArgs)e.StagingItem.Input; switch (keyArgs.KeyboardDevice.Modifiers) { case ModifierKeys.Alt: switch (keyArgs.Key) { case Key.System: break; default: e.StagingItem.Input.Handled = true; break; } break; case ModifierKeys.None: e.StagingItem.Input.Handled = true; switch (keyArgs.Key) { case Key.Escape: Driver.Exit(); break; } break; default: e.StagingItem.Input.Handled = true; break; } } }
void Current_PreProcessInput(object sender, PreProcessInputEventArgs e) { var ev = e.StagingItem.Input.RoutedEvent; if (ev == Keyboard.PreviewLostKeyboardFocusEvent) { } else if (ev == Keyboard.PreviewGotKeyboardFocusEvent) { mFutureFocus = (IInputElement)e.StagingItem.Input.Source; } else if (ev == Keyboard.LostKeyboardFocusEvent) { FocusedElement = mFutureFocus; } else if (ev == Keyboard.GotKeyboardFocusEvent) { // just to be sure, update to last one //FocusedElement = Keyboard.FocusedElement; // could also do that FocusedElement = (IInputElement)e.StagingItem.Input.Source; } }
private void PreProcessInput(object sender, PreProcessInputEventArgs e) { if (State == KeyTipState.None) { return; } var ev = e.StagingItem.Input.RoutedEvent; if (ev == Keyboard.PreviewKeyUpEvent) { KeyEventArgs args = (KeyEventArgs)e.StagingItem.Input; if (IsKeyTipKey(args)) { ShowKeyTips(); } } else if (ev == Mouse.PreviewMouseDownEvent || ev == Stylus.PreviewStylusDownEvent) { LeaveKeyTipMode(false); } else if (ev == TextCompositionManager.PreviewTextInputEvent) { OnPreviewTextInput((TextCompositionEventArgs)e.StagingItem.Input); } else if (ev == Keyboard.PreviewKeyDownEvent) { KeyEventArgs args = (KeyEventArgs)e.StagingItem.Input; if (IsKeyTipClosingKey(args)) { LeaveKeyTipMode(false); } } else if (ev == Mouse.PreviewMouseWheelEvent) { e.StagingItem.Input.Handled = true; } }
void OnPreProcessInputEventHandler(object sender, PreProcessInputEventArgs e) { CheckDisposed(); var name = e.StagingItem.Input.RoutedEvent.Name; switch (name) { case "PreviewMouseDown": case "PreviewMouseUp": case "MouseDown": case "MouseUp": if (!MouseHoverHintWindow()) { CollActivate(); } break; case "PreviewKeyDown": case "PreviewKeyUp": case "KeyDown": case "KeyUp": case "LostKeyboardFocus": CollActivate(); break; case "PreviewInputReport": case "InputReport": case "QueryCursor": case "PreviewMouseMove": case "MouseMove": break; default: Debug.WriteLine(name); break; } }