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); }
private void PreNotifyInput(object sender, NotifyInputEventArgs e) { RawButtonInputReport buttonInputReport = this.ExtractRawButtonInputReport(e, InputManager.PreviewInputReportEvent); if (buttonInputReport != null) { this.CheckForDisconnectedFocus(); if ((buttonInputReport.Actions & RawButtonActions.Activate) == RawButtonActions.Activate) { for (int index = 0; index < this._buttonState.Length; ++index) { this._buttonState[index] = (byte)0; } this._isActive = true; } if ((buttonInputReport.Actions & RawButtonActions.ButtonDown) == RawButtonActions.ButtonDown) { RawButtonActions rawButtonActions = this.GetNonRedundantActions(e) | RawButtonActions.ButtonDown; e.StagingItem.SetData(this._tagNonRedundantActions, (object)rawButtonActions); e.StagingItem.SetData(this._tagButton, (object)buttonInputReport.Button); ButtonState buttonState = this.GetButtonState(buttonInputReport.Button); ButtonState state = (buttonState & ButtonState.Down) != ButtonState.Down ? buttonState | ButtonState.Down : ButtonState.Down | ButtonState.Held; this.SetButtonState(buttonInputReport.Button, state); if (this._inputManager != null && this._inputManager.MostRecentInputDevice != this) { this._inputManager.MostRecentInputDevice = (InputDevice)this; } } if ((buttonInputReport.Actions & RawButtonActions.ButtonUp) == RawButtonActions.ButtonUp) { RawButtonActions rawButtonActions = this.GetNonRedundantActions(e) | RawButtonActions.ButtonUp; e.StagingItem.SetData(this._tagNonRedundantActions, (object)rawButtonActions); e.StagingItem.SetData(this._tagButton, (object)buttonInputReport.Button); ButtonState buttonState = this.GetButtonState(buttonInputReport.Button); ButtonState state = (buttonState & ButtonState.Down) != ButtonState.Down ? buttonState | ButtonState.Held : buttonState & ButtonState.Held; this.SetButtonState(buttonInputReport.Button, state); if (this._inputManager != null && this._inputManager.MostRecentInputDevice != this) { this._inputManager.MostRecentInputDevice = (InputDevice)this; } } } if (e.StagingItem.Input.RoutedEvent == Buttons.PreviewButtonDownEvent) { this.CheckForDisconnectedFocus(); ButtonEventArgs input = (ButtonEventArgs)e.StagingItem.Input; if (this._previousButton == input.Button) { input._isRepeat = true; } else { this._previousButton = input.Button; input._isRepeat = false; } } else { if (e.StagingItem.Input.RoutedEvent != Buttons.PreviewButtonUpEvent) { return; } this.CheckForDisconnectedFocus(); ((ButtonEventArgs)e.StagingItem.Input)._isRepeat = false; this._previousButton = HardwareButton.None; } }