public override bool Matches(object targetElement, InputEventArgs inputEventArgs) { var args = inputEventArgs as KeyEventArgs; if ((args == null) || !IsDefinedKey(args.Key)) { return false; } Debug.WriteLine("Modifiers: " + Keyboard.Modifiers); if (IsTooLongFromLastKey() || IsWrongModifiers() || IsWrongKey(args.Key)) { currentKeyIndex = 0; return false; } ++currentKeyIndex; if (IsMatchingContinued()) { lastPress = DateTime.Now; inputEventArgs.Handled = true; return false; } currentKeyIndex = 0; Debug.WriteLine("Match completed!"); return true; }
public override bool Matches(object targetElement, InputEventArgs inputEventArgs) { if (this._index >= this._gestures.Count) this._index = 0; KeyEventArgs e = inputEventArgs as KeyEventArgs; if (e == null || IsIgnorableKey(e.Key, e.KeyboardDevice.Modifiers)) { return false; } if (this._index > 0 && (DateTime.Now - this._lastKeyPress) > _keyPressInterval) { this._index = 0; } if (this._gestures[this._index].Matches(targetElement, inputEventArgs)) { this._lastKeyPress = DateTime.Now; this._index++; inputEventArgs.Handled = true; return (this._index == this._gestures.Count); } else { this._index = 0; return false; } }
private void Button_PreviewCSEDown(object sender, InputEventArgs e) { items.IndexOf(files[0]); MainLibraryStack.SelectedIndex = items.IndexOf(files[0]); //items.Remove(files[1]); //items.Insert(0, files[1]); }
protected override bool IsDeviceValid(bool? wasValid, InputEventArgs args) { var motionDevice = args.Device as MotionTrackingDevice; if (motionDevice != null) motionDevice.ShouldPromoteToTouch = true; return true; }
protected override void OnInput(object sender, InputEventArgs e) { if (this._gestureStarted) { base.OnInput(sender, e); } }
public override bool Matches(object targetElement, InputEventArgs inputEventArgs) { var args = inputEventArgs as KeyEventArgs; // Don't execute input binding in case focus is on a textbox if ((inputEventArgs.Device.Target is TextBoxBase || inputEventArgs.Device.Target is WebBrowser) && !(modifers == ModifierKeys.Control || modifers == ModifierKeys.Alt)) return false; if (args == null) return false; bool match; if (useModifiers) match = args.Key == key && args.KeyboardDevice.Modifiers == modifers; else { match = (args.Key == key && args.KeyboardDevice.Modifiers == ModifierKeys.None); // To not interfere with multiple key gestures if (previous == Key.G || previous == Key.N || previous == Key.A) match = false; } previous = args.Key; return match; }
/// /// When overridden in a derived class, determines whether the specified matches the input associated with the specified object. /// /// The target of the command. /// The input event data to compare this gesture to. /// /// true if the gesture matches the input; otherwise, false. /// public override bool Matches(object targetElement, InputEventArgs inputEventArgs) { KeyEventArgs args = inputEventArgs as KeyEventArgs; if (args != null) return (Key == args.Key); else return false; }
private void LeftSlideClick(object sender, InputEventArgs e) { imageIndex--; if (imageIndex < 1) { imageIndex = 8; } SlideShow(imageIndex); timer.Interval = new TimeSpan(0, 0, 4); }
public override bool Matches(object targetElement, InputEventArgs inputEventArgs) { var action = GetExtendedMouseAction(inputEventArgs); if (action != null && extendedMouseAction == action.Value) { return Modifiers == Keyboard.Modifiers; } return base.Matches(targetElement, inputEventArgs); }
private void RightSlideClick(object sender, InputEventArgs e) { imageIndex++; if (imageIndex > 8) { imageIndex = 1; } SlideShow(imageIndex); timer.Interval = new TimeSpan(0, 0, 4); }
public StagingAreaInputItem PushInput(InputEventArgs input, StagingAreaInputItem promote) // Note: this should be a bool, and always use the InputItem available on these args. { if(!_allowAccessToStagingArea) { throw new InvalidOperationException(SR.Get(SRID.NotAllowedToAccessStagingArea)); } return this.UnsecureInputManager.PushInput(input, promote); }
private void LayoutRoot_TouchDown(object sender, InputEventArgs e) { var yi = DataContext as YearItem; if (yi == null) return; yi.Orientation = e.Device.GetOrientation(null) + 90; yi.Position = e.Device.GetPosition(null); yi.Position.X -= 100; yi.Position.Y -= 50; (DataContext as YearItem).ShowText = true; }
public void badgeDoubleTap(object sender, InputEventArgs e) { RaiseEvent(new RoutedEventArgs(RequestLargeViewEvent)); if(e!=null) e.Handled = true; //var ap = DataContext as ArgPoint; //var id = ap.Id; //var zoomedAp = DbCtx.Get().ArgPoint.FirstOrDefault(ap0 => ap0.Id == id); //var zoom = new ZoomWindow(zoomedAp); //zoom.ShowDialog(); }
public override bool Matches(object targetElement, InputEventArgs inputEventArgs) { if (m_hackMode) { KeyEventArgs args = inputEventArgs as KeyEventArgs; return args != null && Keyboard.Modifiers == ModifierKeys.None && this.Key == args.Key; } else { return base.Matches(targetElement, inputEventArgs); } }
public override bool Matches(object targetElement, InputEventArgs inputEventArgs) { // Don't execute input binding in case focus is on a textbox if ((inputEventArgs.Device.Target is TextBoxBase || inputEventArgs.Device.Target is WebBrowser) && !(modifiers == ModifierKeys.Control || modifiers == ModifierKeys.Alt)) return false; var args = inputEventArgs as KeyEventArgs; if ((args == null) || !IsDefinedKey(args.Key)) { return false; } if (_currentKeyIndex != 0 && ((DateTime.Now - _lastKeyPress) > _maximumDelayBetweenKeyPresses)) { //took too long to press next key so reset _currentKeyIndex = 0; return false; } //the modifier only needs to be held down for the first keystroke, but you could also require that the modifier be held down for every keystroke if (_currentKeyIndex == 0 && Modifiers != Keyboard.Modifiers) { //wrong modifiers _currentKeyIndex = 0; return false; } if (_keys[_currentKeyIndex] != args.Key) { //wrong key _currentKeyIndex = 0; return false; } ++_currentKeyIndex; if (_currentKeyIndex != _keys.Count) { //still matching _lastKeyPress = DateTime.Now; inputEventArgs.Handled = true; return false; } //match complete _currentKeyIndex = 0; return true; }
/// <summary> /// On a TouchDown event check whether the MediaElement is /// playing or paused and respond by performing the inverse. /// </summary> void Media_TouchDown(object sender, InputEventArgs e) { if (paused) { BeginStoryboard(Resources["Play"] as Storyboard); Media.Play(); paused = false; } else { BeginStoryboard(Resources["Pause"] as Storyboard); Media.Pause(); paused = true; } }
private static ExtendedMouseAction? GetExtendedMouseAction(InputEventArgs inputEventArgs) { var mouseButtonEventArgs = inputEventArgs as MouseButtonEventArgs; if (mouseButtonEventArgs != null) { switch (mouseButtonEventArgs.ChangedButton) { case MouseButton.XButton1: return ExtendedMouseAction.XButton1Click; case MouseButton.XButton2: return ExtendedMouseAction.XButton2Click; } } return null; }
protected override bool IsDeviceValid(bool? wasValid, InputEventArgs args) { var motionDevice = args.Device as MotionTrackingDevice; if (motionDevice == null) return NotifyTransition(wasValid, motionDevice, true); if (motionDevice.Session == null) return NotifyTransition(wasValid, motionDevice, false); Vector3D vector = motionDevice.Session.Position - motionDevice.Session.ShoulderPosition; if (Math.Abs(vector.Z) > MinimumDistance) return NotifyTransition(wasValid, motionDevice, true); return NotifyTransition(wasValid, motionDevice, false); }
public override bool Matches(object targetElement, InputEventArgs inputEventArgs) { if (inputEventArgs is MouseButtonEventArgs) { MouseButtonEventArgs args = (MouseButtonEventArgs)inputEventArgs; switch (ExtraMouseAction) { case ExtraMouseAction.Back : return args.ChangedButton == MouseButton.XButton1; case ExtraMouseAction.Next : return args.ChangedButton == MouseButton.XButton2; } } return false; }
public override bool Matches(object targetElement, InputEventArgs inputEventArgs) { var args = inputEventArgs as KeyEventArgs; //Console.WriteLine(string.Format("{1} + {0}",args.Key, args.KeyboardDevice.Modifiers)); if ((args == null) || !IsDefinedKey(args.Key)) { return false; } if (_currentKeyIndex != 0 && ((DateTime.Now - _lastKeyPress) > _maximumDelayBetweenKeyPresses)) { //took too long to press next key so reset _currentKeyIndex = 0; return false; } //the modifier only needs to be held down for the first keystroke, but you could also require that the modifier be held down for every keystroke if (_currentKeyIndex == 0 && Modifiers != Keyboard.Modifiers) { //wrong modifiers _currentKeyIndex = 0; return false; } if (_keys[_currentKeyIndex] != args.Key) { //wrong key _currentKeyIndex = 0; return false; } ++_currentKeyIndex; if (_currentKeyIndex != _keys.Count) { //still matching _lastKeyPress = DateTime.Now; inputEventArgs.Handled = true; return false; } //match complete _currentKeyIndex = 0; return true; }
public override bool Matches(object targetElement, InputEventArgs inputEventArgs) { if (!base.Matches(targetElement, inputEventArgs)) return false; if (!(inputEventArgs is MouseWheelEventArgs)) return false; var args = (MouseWheelEventArgs)inputEventArgs; switch (Direction) { case WheelDirection.None: return args.Delta == 0; case WheelDirection.Up: return args.Delta > 0; case WheelDirection.Down: return args.Delta < 0; default: return false; } }
public override bool Matches(object targetElement, InputEventArgs inputEventArgs) { if (base.Matches(targetElement, inputEventArgs)) { MouseWheelEventArgs wheelArgs = inputEventArgs as MouseWheelEventArgs; if (wheelArgs != null) { if (MouseWheelAction == MouseWheelAction.AllMovement || (MouseWheelAction == MouseWheelAction.WheelDown && wheelArgs.Delta < 0) || MouseWheelAction == MouseWheelAction.WheelUp && wheelArgs.Delta > 0) { return true; } } } return false; }
public override bool Matches(object targetElement, InputEventArgs inputEventArgs) { var device = inputEventArgs.Device as MouseDevice; if (device != null) { switch (_mouseButton) { case MouseButton.XButton1: if (device.XButton1 == MouseButtonState.Pressed) return true; break; case MouseButton.XButton2: if (device.XButton2 == MouseButtonState.Pressed) return true; break; } } return false; }
// For performace reasons, we try to reuse these event args. // Allow an existing item to be promoted by keeping the existing dictionary. internal void Reset(InputEventArgs input, StagingAreaInputItem promote) { _input = input; if(promote != null && promote._dictionary != null) { // _dictionary = (Hashtable) promote._dictionary.Clone(); } else { if(_dictionary != null) { _dictionary.Clear(); } else { _dictionary = new Hashtable(); } } }
public void Click(object sender, InputEventArgs e) { aTimer.Stop(); aTimer.Start(); numConseqClicks++; Console.WriteLine("click {0}",numConseqClicks); if (numConseqClicks == 2) { if (_onDoubleClick != null) { _onDoubleClick(sender, e); Console.WriteLine("calling 2 tap"); } } else if (numConseqClicks == 3) { if (_onTripleClick != null) _onTripleClick(sender, e); } }
protected override bool IsDeviceValid(bool? wasValid, InputEventArgs args) { var motionDevice = args.Device as MotionTrackingDevice; if (motionDevice == null) return true; if (motionDevice.Session == null) return false; var element = args.OriginalSource as UIElement; if (element == null) return false; var svi = VisualUtility.FindVisualParent<ScatterViewItem>(element); if (svi == null || !svi.IsContainerActive) return false; motionDevice.ShouldPromoteToTouch = true; return true; }
private void HandleLeftButtonDown(InputEventArgs e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } var clickCount = GetClickCount(e); var modifiers = (Keyboard.Modifiers & ModifierKeys.Shift) | (Keyboard.Modifiers & ModifierKeys.Control); switch (clickCount) { case 1: e.Handled = HandleSingleClick(e, modifiers); break; case 2: e.Handled = HandleDoubleClick(e, modifiers); break; case 3: // Disable triple click e.Handled = true; break; default: e.Handled = false; break; } }
internal override void OnInput(InputEventArgs e) { // Text input will start an edit if (e is TextCompositionEventArgs) { BeginEdit(e); } }
public bool ProcessInput(InputEventArgs input) { return(default(bool)); }
public abstract bool Matches(Object targetElement, InputEventArgs inputEventArgs);
/// <summary> /// Scans input and command bindings for matching gestures and executes the appropriate command /// </summary> /// <remarks> /// Scans for command to execute in the following order: /// - input bindings associated with the targetElement instance /// - input bindings associated with the targetElement class /// - command bindings associated with the targetElement instance /// - command bindings associated with the targetElement class /// </remarks> /// <param name="targetElement">UIElement/ContentElement to be scanned for input and command bindings</param> /// <param name="inputEventArgs">InputEventArgs to be matched against for gestures</param> internal static void TranslateInput(IInputElement targetElement, InputEventArgs inputEventArgs) { if ((targetElement == null) || (inputEventArgs == null)) { return; } ICommand command = null; IInputElement target = null; object parameter = null; // Determine UIElement/ContentElement/Neither type DependencyObject targetElementAsDO = targetElement as DependencyObject; bool isUIElement = InputElement.IsUIElement(targetElementAsDO); bool isContentElement = !isUIElement && InputElement.IsContentElement(targetElementAsDO); bool isUIElement3D = !isUIElement && !isContentElement && InputElement.IsUIElement3D(targetElementAsDO); // Step 1: Check local input bindings InputBindingCollection localInputBindings = null; if (isUIElement) { localInputBindings = ((UIElement)targetElement).InputBindingsInternal; } else if (isContentElement) { localInputBindings = ((ContentElement)targetElement).InputBindingsInternal; } else if (isUIElement3D) { localInputBindings = ((UIElement3D)targetElement).InputBindingsInternal; } if (localInputBindings != null) { InputBinding inputBinding = localInputBindings.FindMatch(targetElement, inputEventArgs); if (inputBinding != null) { command = inputBinding.Command; target = inputBinding.CommandTarget; parameter = inputBinding.CommandParameter; } } // Step 2: If no command, check class input bindings if (command == null) { lock (_classInputBindings.SyncRoot) { Type classType = targetElement.GetType(); while (classType != null) { InputBindingCollection classInputBindings = _classInputBindings[classType] as InputBindingCollection; if (classInputBindings != null) { InputBinding inputBinding = classInputBindings.FindMatch(targetElement, inputEventArgs); if (inputBinding != null) { command = inputBinding.Command; target = inputBinding.CommandTarget; parameter = inputBinding.CommandParameter; break; } } classType = classType.BaseType; } } } // Step 3: If no command, check local command bindings if (command == null) { // Check for the instance level ones Next CommandBindingCollection localCommandBindings = null; if (isUIElement) { localCommandBindings = ((UIElement)targetElement).CommandBindingsInternal; } else if (isContentElement) { localCommandBindings = ((ContentElement)targetElement).CommandBindingsInternal; } else if (isUIElement3D) { localCommandBindings = ((UIElement3D)targetElement).CommandBindingsInternal; } if (localCommandBindings != null) { command = localCommandBindings.FindMatch(targetElement, inputEventArgs); } } // Step 4: If no command, look at class command bindings if (command == null) { lock (_classCommandBindings.SyncRoot) { Type classType = targetElement.GetType(); while (classType != null) { CommandBindingCollection classCommandBindings = _classCommandBindings[classType] as CommandBindingCollection; if (classCommandBindings != null) { command = classCommandBindings.FindMatch(targetElement, inputEventArgs); if (command != null) { break; } } classType = classType.BaseType; } } } // Step 5: If found a command, then execute it (unless it is // the special "NotACommand" command, which we simply ignore without // setting Handled=true, so that the input bubbles up to the parent) if (command != null && command != ApplicationCommands.NotACommand) { // We currently do not support declaring the element with focus as the target // element by setting target == null. Instead, we interpret a null target to indicate // the element that we are routing the event through, e.g. the targetElement parameter. if (target == null) { target = targetElement; } bool continueRouting = false; RoutedCommand routedCommand = command as RoutedCommand; if (routedCommand != null) { if (routedCommand.CriticalCanExecute(parameter, target, inputEventArgs.UserInitiated /*trusted*/, out continueRouting)) { // If the command can be executed, we never continue to route the // input event. continueRouting = false; ExecuteCommand(routedCommand, parameter, target, inputEventArgs); } } else { if (command.CanExecute(parameter)) { command.Execute(parameter); } } // If we mapped an input event to a command, we should always // handle the input event - regardless of whether the command // was executed or not. Unless the CanExecute handler told us // to continue the route. inputEventArgs.Handled = !continueRouting; } }
private static bool ExecuteCommand(RoutedCommand routedCommand, object parameter, IInputElement target, InputEventArgs inputEventArgs) { return(routedCommand.ExecuteCore(parameter, target, inputEventArgs.UserInitiated)); }
private bool ProcessStagingArea() { bool handled = false; // For performance reasons, try to reuse the input event args. // If we are reentrered, we have to start over with fresh event // args, so we clear the member variables before continuing. // Also, we cannot simply make an single instance of the // PreProcessedInputEventArgs and cast it to NotifyInputEventArgs // or ProcessInputEventArgs because a malicious user could upcast // the object and call inappropriate methods. NotifyInputEventArgs notifyInputEventArgs = (_notifyInputEventArgs != null) ? _notifyInputEventArgs : new NotifyInputEventArgs(); ProcessInputEventArgs processInputEventArgs = (_processInputEventArgs != null) ? _processInputEventArgs : new ProcessInputEventArgs(); PreProcessInputEventArgs preProcessInputEventArgs = (_preProcessInputEventArgs != null) ? _preProcessInputEventArgs : new PreProcessInputEventArgs(); _notifyInputEventArgs = null; _processInputEventArgs = null; _preProcessInputEventArgs = null; // Because we can be reentered, we can't just enumerate over the // staging area - that could throw an exception if the queue // changes underneath us. Instead, just loop until we find a // frame marker or until the staging area is empty. StagingAreaInputItem item = null; while ((item = PopInput()) != null) { // If we found a marker, we have reached the end of a // "section" of the staging area. We just return from // the synchronous processing of the staging area. // If a dispatcher frame has been pushed by someone, this // will not return to the original ProcessInput. Instead // it will unwind to the dispatcher and since we have // already pushed a work item to continue processing the // input, it will simply call back into us to do more // processing. At which point we will continue to drain // the staging area. This could cause strage behavior, // but it is deemed more acceptable than stalling input // processing. // if (item.IsMarker) { break; } // Pre-Process the input. This could modify the staging // area, and it could cancel the processing of this // input event. // // Because we use multi-cast delegates, we always have to // create a new multi-cast delegate when we add or remove // a handler. This means we can just call the current // multi-cast delegate instance, and it is safe to iterate // over, even if we get reentered. if (_preProcessInput != null) { preProcessInputEventArgs.Reset(item, this); // Invoke the handlers in reverse order so that handlers that // users add are invoked before handlers in the system. Delegate[] handlers = _preProcessInput.GetInvocationList(); for (int i = (handlers.Length - 1); i >= 0; i--) { PreProcessInputEventHandler handler = (PreProcessInputEventHandler)handlers[i]; handler(this, preProcessInputEventArgs); } } if (!preProcessInputEventArgs.Canceled) { // Pre-Notify the input. // // Because we use multi-cast delegates, we always have to // create a new multi-cast delegate when we add or remove // a handler. This means we can just call the current // multi-cast delegate instance, and it is safe to iterate // over, even if we get reentered. if (_preNotifyInput != null) { notifyInputEventArgs.Reset(item, this); // Invoke the handlers in reverse order so that handlers that // users add are invoked before handlers in the system. Delegate[] handlers = _preNotifyInput.GetInvocationList(); for (int i = (handlers.Length - 1); i >= 0; i--) { NotifyInputEventHandler handler = (NotifyInputEventHandler)handlers[i]; handler(this, notifyInputEventArgs); } } // Raise the input event being processed. InputEventArgs input = item.Input; // Some input events are explicitly associated with // an element. Those that are not are associated with // the target of the input device for this event. DependencyObject eventSource = input.Source as DependencyObject; if (eventSource == null || !InputElement.IsValid(eventSource as IInputElement)) { if (input.Device != null) { eventSource = input.Device.Target as DependencyObject; } } // During synchronized input processing, event should be discarded if not listening for this input type. if (_isSynchronizedInput && SynchronizedInputHelper.IsMappedEvent(input) && Array.IndexOf(SynchronizedInputEvents, input.RoutedEvent) < 0 && Array.IndexOf(PairedSynchronizedInputEvents, input.RoutedEvent) < 0) { if (!SynchronizedInputHelper.ShouldContinueListening(input)) { // Discard the event _synchronizedInputState = SynchronizedInputStates.Discarded; SynchronizedInputHelper.RaiseAutomationEvents(); CancelSynchronizedInput(); } else { _synchronizedInputAsyncClearOperation = Dispatcher.BeginInvoke((Action) delegate { // Discard the event _synchronizedInputState = SynchronizedInputStates.Discarded; SynchronizedInputHelper.RaiseAutomationEvents(); CancelSynchronizedInput(); }, DispatcherPriority.Background); } } else { if (eventSource != null) { if (InputElement.IsUIElement(eventSource)) { UIElement e = (UIElement)eventSource; e.RaiseEvent(input, true); // Call the "trusted" flavor of RaiseEvent. } else if (InputElement.IsContentElement(eventSource)) { ContentElement ce = (ContentElement)eventSource; ce.RaiseEvent(input, true);// Call the "trusted" flavor of RaiseEvent. } else if (InputElement.IsUIElement3D(eventSource)) { UIElement3D e3D = (UIElement3D)eventSource; e3D.RaiseEvent(input, true); // Call the "trusted" flavor of RaiseEvent } // If synchronized input raise appropriate automation event. if (_isSynchronizedInput && SynchronizedInputHelper.IsListening(_listeningElement, input)) { if (!SynchronizedInputHelper.ShouldContinueListening(input)) { SynchronizedInputHelper.RaiseAutomationEvents(); CancelSynchronizedInput(); } else { _synchronizedInputAsyncClearOperation = Dispatcher.BeginInvoke((Action) delegate { SynchronizedInputHelper.RaiseAutomationEvents(); CancelSynchronizedInput(); }, DispatcherPriority.Background); } } } } // Post-Notify the input. // // Because we use multi-cast delegates, we always have to // create a new multi-cast delegate when we add or remove // a handler. This means we can just call the current // multi-cast delegate instance, and it is safe to iterate // over, even if we get reentered. if (_postNotifyInput != null) { notifyInputEventArgs.Reset(item, this); // Invoke the handlers in reverse order so that handlers that // users add are invoked before handlers in the system. Delegate[] handlers = _postNotifyInput.GetInvocationList(); for (int i = (handlers.Length - 1); i >= 0; i--) { NotifyInputEventHandler handler = (NotifyInputEventHandler)handlers[i]; handler(this, notifyInputEventArgs); } } // Post-Process the input. This could modify the staging // area. // // Because we use multi-cast delegates, we always have to // create a new multi-cast delegate when we add or remove // a handler. This means we can just call the current // multi-cast delegate instance, and it is safe to iterate // over, even if we get reentered. if (_postProcessInput != null) { processInputEventArgs.Reset(item, this); RaiseProcessInputEventHandlers(_postProcessInput, processInputEventArgs); // PreviewInputReport --> InputReport if (item.Input.RoutedEvent == InputManager.PreviewInputReportEvent) { if (!item.Input.Handled) { InputReportEventArgs previewInputReport = (InputReportEventArgs)item.Input; InputReportEventArgs inputReport = new InputReportEventArgs(previewInputReport.Device, previewInputReport.Report); inputReport.RoutedEvent = InputManager.InputReportEvent; PushInput(inputReport, item); } } } if (input.Handled) { handled = true; } } } // Store our input event args so that we can use them again, and // avoid having to allocate more. _notifyInputEventArgs = notifyInputEventArgs; _processInputEventArgs = processInputEventArgs; _preProcessInputEventArgs = preProcessInputEventArgs; // Make sure to throw away the contents of the event args so // we don't keep refs around to things we don't mean to. _notifyInputEventArgs.Reset(null, null); _processInputEventArgs.Reset(null, null); _preProcessInputEventArgs.Reset(null, null); return(handled); }
private void PostProcessInput(object sender, ProcessInputEventArgs e) { InputEventArgs inputEventArgs = e.StagingItem.Input; if (inputEventArgs.Device == this) { RoutedEvent routedEvent = inputEventArgs.RoutedEvent; if (routedEvent == Manipulation.ManipulationDeltaEvent) { ManipulationDeltaEventArgs deltaEventArgs = inputEventArgs as ManipulationDeltaEventArgs; if (deltaEventArgs != null) { // During deltas, see if panning feedback is needed on the window ManipulationDelta unusedManipulation = deltaEventArgs.UnusedManipulation; _manipulationLogic.RaiseBoundaryFeedback(unusedManipulation, deltaEventArgs.RequestedComplete); _manipulationLogic.PushEventsToDevice(); // If a Complete is requested, then pass it along to the manipulation processor if (deltaEventArgs.RequestedComplete) { _manipulationLogic.Complete(/* withInertia = */ deltaEventArgs.RequestedInertia); _manipulationLogic.PushEventsToDevice(); } else if (deltaEventArgs.RequestedCancel) { Debug.Assert(!deltaEventArgs.IsInertial); OnManipulationCancel(); } } } else if (routedEvent == Manipulation.ManipulationStartingEvent) { ManipulationStartingEventArgs startingEventArgs = inputEventArgs as ManipulationStartingEventArgs; if (startingEventArgs != null && startingEventArgs.RequestedCancel) { OnManipulationCancel(); } } else if (routedEvent == Manipulation.ManipulationStartedEvent) { ManipulationStartedEventArgs startedEventArgs = inputEventArgs as ManipulationStartedEventArgs; if (startedEventArgs != null) { if (startedEventArgs.RequestedComplete) { // If a Complete is requested, pass it along to the manipulation processor _manipulationLogic.Complete(/* withInertia = */ false); _manipulationLogic.PushEventsToDevice(); } else if (startedEventArgs.RequestedCancel) { OnManipulationCancel(); } else { // Start ticking to produce delta events ResumeAllTicking(); // Resumes the ticking of all the suspended devices on the thread StartTicking(); // Ensures that we continue ticking or restart ticking for this device } } } else if (routedEvent == Manipulation.ManipulationInertiaStartingEvent) { // Switching from using rendering for ticking to a timer at lower priority (handled by ManipulationLogic) StopTicking(); // Remove all the manipulators so that we dont re-start manipulations accidentally RemoveAllManipulators(); // Initialize inertia ManipulationInertiaStartingEventArgs inertiaEventArgs = inputEventArgs as ManipulationInertiaStartingEventArgs; if (inertiaEventArgs != null) { if (inertiaEventArgs.RequestedCancel) { OnManipulationCancel(); } else { _manipulationLogic.BeginInertia(inertiaEventArgs); } } } else if (routedEvent == Manipulation.ManipulationCompletedEvent) { _manipulationLogic.OnCompleted(); ManipulationCompletedEventArgs completedEventArgs = inputEventArgs as ManipulationCompletedEventArgs; if (completedEventArgs != null) { if (completedEventArgs.RequestedCancel) { Debug.Assert(!completedEventArgs.IsInertial); OnManipulationCancel(); } else if (!(completedEventArgs.IsInertial && _ticking)) { // Remove the manipulation device only if // another manipulation didnot start OnManipulationComplete(); } } } else if (routedEvent == Manipulation.ManipulationBoundaryFeedbackEvent) { ManipulationBoundaryFeedbackEventArgs boundaryEventArgs = inputEventArgs as ManipulationBoundaryFeedbackEventArgs; if (boundaryEventArgs != null) { _compensateForBoundaryFeedback = boundaryEventArgs.CompensateForBoundaryFeedback; } } } }
internal void ProcessManipulationInput(InputEventArgs e) { EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordInput | EventTrace.Keyword.KeywordPerf, EventTrace.Level.Info, EventTrace.Event.ManipulationEventRaised, 0); _inputManager.ProcessInput(e); }
// internal virtual void OnInput(InputEventArgs e) { }
internal void BeginEdit(InputEventArgs e, bool handled) { var owner = DataGridOwner; if (owner != null) { if (owner.BeginEdit(e)) { e.Handled |= handled; } } }
private void PushEvent(InputEventArgs e) { // We only expect to generate one event at a time and should never need a queue. Debug.Assert(_generatedEvent == null, "There is already a generated event waiting to be pushed."); _generatedEvent = e; }