private void PostProcessInput(object sender, ProcessInputEventArgs e) { if (!e.StagingItem.Input.Handled) { var routedEvent = e.StagingItem.Input.RoutedEvent; if (routedEvent == InputManager.InputReportEvent) { if (e.StagingItem.Input is InputReportEventArgs input) { if (input.Report is RawTouchInputReport report) { var args = new TouchEventArgs( this, report.Timestamp, report.Touches); var target = report.Target; if (report.EventMessage == (byte)TouchMessages.Down) { args.RoutedEvent = TouchEvents.TouchDownEvent; } else if (report.EventMessage == (byte)TouchMessages.Up) { args.RoutedEvent = TouchEvents.TouchUpEvent; } else if (report.EventMessage == (byte)TouchMessages.Move) { args.RoutedEvent = TouchEvents.TouchMoveEvent; } else throw new Exception("Unknown touch event."); args.Source = (target ?? this._focus); e.PushInput(args, e.StagingItem); } } } } }
private void PostProcessInput(object sender, ProcessInputEventArgs e) { InputReportEventArgs args; RawTouchInputReport report; if ((!e.StagingItem.Input.Handled && (e.StagingItem.Input.RoutedEvent == InputManager.InputReportEvent)) && (((args = e.StagingItem.Input as InputReportEventArgs) != null) && ((report = args.Report as RawTouchInputReport) != null))) { TouchEventArgs input = new TouchEventArgs(this, report.Timestamp, report.Touches); UIElement target = report.Target; if (report.EventMessage == 1) { input.RoutedEvent = TouchEvents.TouchDownEvent; } else if (report.EventMessage == 2) { input.RoutedEvent = TouchEvents.TouchUpEvent; } else { if (report.EventMessage != 3) { throw new Exception("Unknown touch event."); } input.RoutedEvent = TouchEvents.TouchMoveEvent; } input.Source = target ?? this._focus; e.PushInput(input, e.StagingItem); } }
private void PostProcessInput(object sender, ProcessInputEventArgs e) { InputReportEventArgs args; RawGenericInputReport report; if ((((args = e.StagingItem.Input as InputReportEventArgs) != null) && (args.RoutedEvent == InputManager.InputReportEvent)) && (((report = args.Report as RawGenericInputReport) != null) && !e.StagingItem.Input.Handled)) { GenericEvent internalEvent = report.InternalEvent; GenericEventArgs input = new GenericEventArgs(this, report.InternalEvent) { RoutedEvent = GenericEvents.GenericStandardEvent }; if (report.Target != null) { input.Source = report.Target; } e.PushInput(input, e.StagingItem); } }
private void PostProcessInput(object sender, ProcessInputEventArgs e) { // PreviewButtonDown --> ButtonDown if (e.StagingItem.Input.RoutedEvent == Buttons.PreviewButtonDownEvent) { CheckForDisconnectedFocus(); if (!e.StagingItem.Input.Handled) { var previewButtonDown = (ButtonEventArgs)e.StagingItem.Input; var buttonDown = new ButtonEventArgs(this, previewButtonDown.InputSource, previewButtonDown.Timestamp, previewButtonDown.Button) { _isRepeat = previewButtonDown.IsRepeat, RoutedEvent = Buttons.ButtonDownEvent }; e.PushInput(buttonDown, e.StagingItem); } } // PreviewButtonUp --> ButtonUp if (e.StagingItem.Input.RoutedEvent == Buttons.PreviewButtonUpEvent) { CheckForDisconnectedFocus(); if (!e.StagingItem.Input.Handled) { var previewButtonUp = (ButtonEventArgs)e.StagingItem.Input; var buttonUp = new ButtonEventArgs(this, previewButtonUp.InputSource, previewButtonUp.Timestamp, previewButtonUp.Button) { RoutedEvent = Buttons.ButtonUpEvent }; e.PushInput(buttonUp, e.StagingItem); } } var buttonInput = ExtractRawButtonInputReport(e, InputManager.InputReportEvent); if (buttonInput != null) { CheckForDisconnectedFocus(); if (!e.StagingItem.Input.Handled) { // In general, this is where we promote the non-redundant // reported actions to our premier events. var actions = GetNonRedundantActions(e); // Raw --> PreviewButtonDown if ((actions & RawButtonActions.ButtonDown) == RawButtonActions.ButtonDown) { var button = (HardwareButton)e.StagingItem.GetData(this._tagButton); if (button != HardwareButton.None) { var previewButtonDown = new ButtonEventArgs(this, buttonInput.InputSource, buttonInput.Timestamp, button) { RoutedEvent = Buttons.PreviewButtonDownEvent }; e.PushInput(previewButtonDown, e.StagingItem); } } // Raw --> PreviewButtonUp if ((actions & RawButtonActions.ButtonUp) == RawButtonActions.ButtonUp) { var button = (HardwareButton)e.StagingItem.GetData(this._tagButton); if (button != HardwareButton.None) { var previewButtonUp = new ButtonEventArgs(this, buttonInput.InputSource, buttonInput.Timestamp, button) { RoutedEvent = Buttons.PreviewButtonUpEvent }; e.PushInput(previewButtonUp, e.StagingItem); } } } // Deactivate if ((buttonInput.Actions & RawButtonActions.Deactivate) == RawButtonActions.Deactivate) { if (this._isActive) { this._isActive = false; // Even if handled, a button deactivate results in a lost focus. ChangeFocus(null, e.StagingItem.Input.Timestamp); } } } }
private void PostProcessInput(object sender, ProcessInputEventArgs e) { if (e.StagingItem.Input.RoutedEvent == Buttons.PreviewButtonDownEvent) { this.CheckForDisconnectedFocus(); if (!e.StagingItem.Input.Handled) { ButtonEventArgs input = (ButtonEventArgs)e.StagingItem.Input; ButtonEventArgs buttonEventArgs1 = new ButtonEventArgs(this, input.InputSource, input.Timestamp, input.Button); buttonEventArgs1._isRepeat = input.IsRepeat; buttonEventArgs1.RoutedEvent = Buttons.ButtonDownEvent; ButtonEventArgs buttonEventArgs2 = buttonEventArgs1; e.PushInput((InputEventArgs)buttonEventArgs2, e.StagingItem); } } if (e.StagingItem.Input.RoutedEvent == Buttons.PreviewButtonUpEvent) { this.CheckForDisconnectedFocus(); if (!e.StagingItem.Input.Handled) { ButtonEventArgs input = (ButtonEventArgs)e.StagingItem.Input; ButtonEventArgs buttonEventArgs1 = new ButtonEventArgs(this, input.InputSource, input.Timestamp, input.Button); buttonEventArgs1.RoutedEvent = Buttons.ButtonUpEvent; ButtonEventArgs buttonEventArgs2 = buttonEventArgs1; e.PushInput((InputEventArgs)buttonEventArgs2, e.StagingItem); } } RawButtonInputReport buttonInputReport = this.ExtractRawButtonInputReport((NotifyInputEventArgs)e, InputManager.InputReportEvent); if (buttonInputReport == null) { return; } this.CheckForDisconnectedFocus(); if (!e.StagingItem.Input.Handled) { int redundantActions = (int)this.GetNonRedundantActions((NotifyInputEventArgs)e); if ((redundantActions & 1) == 1) { HardwareButton data = (HardwareButton)e.StagingItem.GetData(this._tagButton); if (data != HardwareButton.None) { ButtonEventArgs buttonEventArgs1 = new ButtonEventArgs(this, buttonInputReport.InputSource, buttonInputReport.Timestamp, data); buttonEventArgs1.RoutedEvent = Buttons.PreviewButtonDownEvent; ButtonEventArgs buttonEventArgs2 = buttonEventArgs1; e.PushInput((InputEventArgs)buttonEventArgs2, e.StagingItem); } } if ((redundantActions & 2) == 2) { HardwareButton data = (HardwareButton)e.StagingItem.GetData(this._tagButton); if (data != HardwareButton.None) { ButtonEventArgs buttonEventArgs1 = new ButtonEventArgs(this, buttonInputReport.InputSource, buttonInputReport.Timestamp, data); buttonEventArgs1.RoutedEvent = Buttons.PreviewButtonUpEvent; ButtonEventArgs buttonEventArgs2 = buttonEventArgs1; e.PushInput((InputEventArgs)buttonEventArgs2, e.StagingItem); } } } if ((buttonInputReport.Actions & RawButtonActions.Deactivate) != RawButtonActions.Deactivate || !this._isActive) { return; } this._isActive = false; this.ChangeFocus((UIElement)null, e.StagingItem.Input.Timestamp); }