Esempio n. 1
0
        // CSS Added for keyboard interop
        // Catch WM_CHAR messages which weren't handled by Avalon
        //  (including mnemonics which were typed without the "Alt" key)
        private void InputManager_PostProcessInput(object sender, SWI.ProcessInputEventArgs e)
        {
            // Should return immediately if this WFH is not in the active Window
            PresentationSource presentationSource = PresentationSource.FromVisual(this._host);

            if (presentationSource == null)
            {
                return;
            }
            Window presentationSourceWindow = presentationSource.RootVisual as Window;

            //CSS This active window check may not work for multiple levels of nesting...
            // RootVisual isn't top level window.  Should we traverse upward through nested levels?
            if (presentationSourceWindow == null || !presentationSourceWindow.IsActive)
            {
                return;
            }

            // Now check for unhandled WM_CHAR messages and process them as mnemonics
            if (!e.StagingItem.Input.Handled && e.StagingItem.Input.RoutedEvent == SWI.TextCompositionManager.TextInputEvent)
            {
                SWI.TextCompositionEventArgs te = (SWI.TextCompositionEventArgs)e.StagingItem.Input;
                string text = te.Text;
                if (string.IsNullOrEmpty(text))
                {
                    text = te.SystemText;
                }
                if (!string.IsNullOrEmpty(text))
                {
                    e.StagingItem.Input.Handled = this.ProcessDialogChar(text[0]);
                }
            }
        }
Esempio n. 2
0
        private void PostProcessInput(object sender, ProcessInputEventArgs e)
        {
            TextServicesContext context;
            KeyEventArgs        keyArgs;

            if (!TextServicesLoader.ServicesInstalled)
            {
                return;
            }

            // IMM32-IME handles the key event and we don't do anything.
            if (InputMethod.IsImm32ImeCurrent())
            {
                return;
            }

            DependencyObject element = Keyboard.FocusedElement as DependencyObject;

            if ((element == null) || (bool)element.GetValue(InputMethod.IsInputMethodSuspendedProperty))
            {
                // The focus is on the element that suspending IME's input (such as menu).
                // we don't do anything.
                return;
            }

            if (e.StagingItem.Input.RoutedEvent == Keyboard.PreviewKeyDownEvent ||
                e.StagingItem.Input.RoutedEvent == Keyboard.PreviewKeyUpEvent)
            {
                // filter SysKey
                if (IsSysKeyDown())
                {
                    return;
                }

                keyArgs = (KeyEventArgs)e.StagingItem.Input;

                if (!keyArgs.Handled && keyArgs.Key == Key.ImeProcessed)
                {
                    context = TextServicesContext.DispatcherCurrent;

                    if (context != null)
                    {
                        if (TextServicesKeystroke(context, keyArgs, false /* test */))
                        {
                            keyArgs.Handled = true;
                        }
                    }
                }
            }
            else if (e.StagingItem.Input.RoutedEvent == Keyboard.KeyDownEvent ||
                     e.StagingItem.Input.RoutedEvent == Keyboard.KeyUpEvent)
            {
                keyArgs = (KeyEventArgs)e.StagingItem.Input;
                if (!keyArgs.Handled && keyArgs.Key == Key.ImeProcessed)
                {
                    keyArgs.Handled = true;
                }
            }
        }
 private void OnPostProcessInput(object sender, ProcessInputEventArgs e)
 {
     if (e.StagingItem.Input.RoutedEvent == Keyboard.KeyDownEvent)
     {
         KeyEventArgs keyArgs = (KeyEventArgs)e.StagingItem.Input;
         ProcessKeyDown(sender, keyArgs);
     }
 }
        private void Current_PostProcessInput(object sender, ProcessInputEventArgs e)
        {
            Point pt = Mouse.GetPosition(this);

            if (_currentMousePosition == pt)
                return;

            _currentMousePosition = pt;
            UpdateViewBox();
            InvalidateArrange();
        }
Esempio n. 5
0
		static void PostProcessInput(object sender, ProcessInputEventArgs e)
		{
			if (CurrentListener != null) {
				var a = e.StagingItem.Input as KeyEventArgs;
				if (a != null && a.Key == Key.Escape) {
					Mouse.Capture(null);
					CurrentListener.IsDown = false;
					CurrentListener.IsCanceled = true;
					CurrentListener.Complete();
				}
			}
		}
Esempio n. 6
0
        private void PostProcessInput(object sender, ProcessInputEventArgs e)
        {
            if (e.StagingItem.Input.Handled)
            {
                return;
            }

            if (e.StagingItem.Input.RoutedEvent == Keyboard.KeyDownEvent)
            {
                OnKeyDown((KeyEventArgs)e.StagingItem.Input);
            }
            else if (e.StagingItem.Input.RoutedEvent == TextCompositionManager.TextInputEvent)
            {
                OnText((TextCompositionEventArgs)e.StagingItem.Input);
            }
        }
Esempio n. 7
0
        private void PostProcessInput(object sender, ProcessInputEventArgs e)
        {
            InputEventArgs inputEventArgs = e.StagingItem.Input;

            if ((inputEventArgs != null) && (inputEventArgs.Device == this))
            {
                if (inputEventArgs.Handled)
                {
                    RoutedEvent routedEvent = inputEventArgs.RoutedEvent;

                    if (routedEvent == Touch.PreviewTouchMoveEvent ||
                        routedEvent == Touch.TouchMoveEvent)
                    {
                        _lastMoveHandled = true;
                    }
                    else if (routedEvent == Touch.PreviewTouchDownEvent ||
                             routedEvent == Touch.TouchDownEvent)
                    {
                        _lastDownHandled = true;
                    }
                    else if (routedEvent == Touch.PreviewTouchUpEvent ||
                             routedEvent == Touch.TouchUpEvent)
                    {
                        _lastUpHandled = true;
                    }
                }
                else
                {
                    bool        forManipulation;
                    RoutedEvent promotedTouchEvent = PromotePreviewToMain(inputEventArgs.RoutedEvent, out forManipulation);
                    if (promotedTouchEvent != null)
                    {
                        TouchEventArgs promotedTouchEventArgs = CreateEventArgs(promotedTouchEvent);
                        e.PushInput(promotedTouchEventArgs, e.StagingItem);
                    }
                    else if (forManipulation)
                    {
                        UIElement manipulatableElement = GetManipulatableElement();
                        if (manipulatableElement != null)
                        {
                            PromoteMainToManipulation(manipulatableElement, (TouchEventArgs)inputEventArgs);
                        }
                    }
                }
            }
        }
Esempio n. 8
0
 private void PostProcessInput(object sender, ProcessInputEventArgs e)
 {
     if (e.StagingItem.Input.RoutedEvent == InputManager.InputReportEvent)
     {
         if (!e.StagingItem.Input.Handled)
         {
             InputReportEventArgs inputReportEventArgs = e.StagingItem.Input as InputReportEventArgs;
             if (inputReportEventArgs != null)
             {
                 RawAppCommandInputReport rawAppCommandInputReport = inputReportEventArgs.Report as RawAppCommandInputReport;
                 if (rawAppCommandInputReport != null)
                 {
                     IInputElement commandTarget = e.StagingItem.Input.OriginalSource as IInputElement;
                     if (commandTarget != null)
                     {
                         RoutedCommand command = GetRoutedCommand(rawAppCommandInputReport.AppCommand);
                         if (command != null)
                         {
                             // Send the app command to the tree to be handled by UIElements and ContentElements
                             // that will forward the event to CommandManager.
                             CommandDeviceEventArgs args = new CommandDeviceEventArgs(this, rawAppCommandInputReport.Timestamp, command);
                             args.RoutedEvent = CommandDeviceEvent;
                             args.Source      = commandTarget;
                             e.PushInput(args, e.StagingItem);
                         }
                     }
                 }
             }
         }
     }
     else if (e.StagingItem.Input.RoutedEvent == Keyboard.KeyUpEvent ||
              e.StagingItem.Input.RoutedEvent == Mouse.MouseUpEvent ||
              e.StagingItem.Input.RoutedEvent == Keyboard.GotKeyboardFocusEvent ||
              e.StagingItem.Input.RoutedEvent == Keyboard.LostKeyboardFocusEvent)
     {
         CommandManager.InvalidateRequerySuggested();
     }
 }
Esempio n. 9
0
        public bool ProcessInput(InputEventArgs input)
        {
            StagingAreaInputItem stagingItem = new StagingAreaInputItem(input);

            PreProcessInputEventArgs preProcessArgs = new PreProcessInputEventArgs(this, stagingItem);

            if (PreProcessInput != null)
            {
                PreProcessInput(this, preProcessArgs);
            }

            NotifyInputEventArgs notifyArgs = new NotifyInputEventArgs(this, stagingItem);

            if (PreNotifyInput != null)
            {
                PreNotifyInput(this, notifyArgs);
            }

#if notyet
            if (!preProcessArgs.Canceled)
            {
                /* XXX route the event */;
            }
#endif

            if (PostNotifyInput != null)
            {
                PostNotifyInput(this, notifyArgs);
            }

            if (PostProcessInput != null)
            {
                ProcessInputEventArgs processArgs = new ProcessInputEventArgs(this, stagingItem);
                PostProcessInput(this, processArgs);
            }

            return(true);
        }
		private void PostProcessInput(object sender, ProcessInputEventArgs e)
		{
			if (e.StagingItem.Input.RoutedEvent == Keyboard.KeyDownEvent)
			{
				var args = (KeyEventArgs)e.StagingItem.Input;
				if (args.Handled)
					return;

				if (State == KeyTipState.None && IsKeyTipKey(args))
				{
					var src = args.OriginalSource as DependencyObject;
					if (EnterKeyTipMode(src.VisualHierarchy().Last(), args.Key != Key.F10))
					{
						args.Handled = true;
					}
				}
				else if (State != KeyTipState.None && args.Key == Key.Escape)
				{
					PopKeyTipScope();
					args.Handled = true;
				}
			}
		}
Esempio n. 11
0
        void PromotePreviewToMain(ProcessInputEventArgs e) 
        { 
            if (!e.StagingItem.Input.Handled)
            { 
                RoutedEvent eventMain = GetMainEventFromPreviewEvent(e.StagingItem.Input.RoutedEvent);
                if (eventMain != null)
                {
                    StylusEventArgs eventArgsPreview = (StylusEventArgs)e.StagingItem.Input; 
                    StylusDevice stylusDevice = eventArgsPreview.InputReport.StylusDevice;
 
                    StylusEventArgs eventArgsMain; 
                    if (eventMain == Stylus.StylusDownEvent ||
                        eventMain == Stylus.PreviewStylusDownEvent) 
                    {
                        StylusDownEventArgs downEventArgsPreview = (StylusDownEventArgs)eventArgsPreview;
                        eventArgsMain = new StylusDownEventArgs(stylusDevice, eventArgsPreview.Timestamp);
                    } 
                    else if (eventMain == Stylus.StylusButtonDownEvent ||
                        eventMain == Stylus.StylusButtonUpEvent) 
                    { 
                        StylusButtonEventArgs buttonEventArgsPreview = (StylusButtonEventArgs)eventArgsPreview;
                        eventArgsMain = new StylusButtonEventArgs(stylusDevice, eventArgsPreview.Timestamp, buttonEventArgsPreview.StylusButton); 
                    }
                    else if (eventMain != Stylus.StylusSystemGestureEvent)
                    {
                        eventArgsMain = new StylusEventArgs(stylusDevice, eventArgsPreview.Timestamp); 
                    }
                    else 
                    { 
                        StylusSystemGestureEventArgs previewSystemGesture = (StylusSystemGestureEventArgs)eventArgsPreview;
                        eventArgsMain = new StylusSystemGestureEventArgs(stylusDevice, 
                                                                         previewSystemGesture.Timestamp,
                                                                         previewSystemGesture.SystemGesture,
                                                                         previewSystemGesture.GestureX,
                                                                         previewSystemGesture.GestureY, 
                                                                         previewSystemGesture.ButtonState);
                    } 
                    eventArgsMain.InputReport = eventArgsPreview.InputReport; 
                    eventArgsMain.RoutedEvent = eventMain;
                    e.PushInput(eventArgsMain, e.StagingItem); 
                }
            }
            else
            { 
                // A TouchDevice is activated before TouchDown and deactivated after TouchUp
                // But if PreviewStylusUp event is handled by the user, it will 
                // never be promoted to TouchUp event leaving the TouchDevice in inconsistent 
                // active state. Hence deactivating touch device if it is active.
                StylusEventArgs stylusEventArgs = e.StagingItem.Input as StylusEventArgs; 
                if (stylusEventArgs != null &&
                    stylusEventArgs.RoutedEvent == Stylus.PreviewStylusUpEvent &&
                    stylusEventArgs.StylusDevice.TouchDevice.IsActive)
                { 
                    stylusEventArgs.StylusDevice.TouchDevice.OnDeactivate();
                } 
            } 
        }
Esempio n. 12
0
        private void RaiseProcessInputEventHandlers(ProcessInputEventHandler postProcessInput, ProcessInputEventArgs processInputEventArgs)
        {
            processInputEventArgs.StagingItem.Input.MarkAsUserInitiated();

            try
            {
                // Invoke the handlers in reverse order so that handlers that
                // users add are invoked before handlers in the system.
                Delegate[] handlers = postProcessInput.GetInvocationList();
                for (int i = (handlers.Length - 1); i >= 0; i--)
                {
                    ProcessInputEventHandler handler = (ProcessInputEventHandler)handlers[i];
                    handler(this, processInputEventArgs);
                }
            }
            finally // we do this in a finally block in case of exceptions
            {
                processInputEventArgs.StagingItem.Input.ClearUserInitiated();
            }
        }
Esempio n. 13
0
        void CallPlugInsForMouse(ProcessInputEventArgs e)
        {
            if (!e.StagingItem.Input.Handled) 
            {
                // if we see a preview mouse event that is not generated by a stylus 
                // then send on to plugin 
                if ((e.StagingItem.Input.RoutedEvent != Mouse.PreviewMouseDownEvent) &&
                    (e.StagingItem.Input.RoutedEvent != Mouse.PreviewMouseUpEvent) && 
                    (e.StagingItem.Input.RoutedEvent != Mouse.PreviewMouseMoveEvent) &&
                    (e.StagingItem.Input.RoutedEvent != InputManager.InputReportEvent))
                    return;
 
                // record the mouse capture for later reference..
                MouseDevice mouseDevice; 
                PresentationSource source; 
                bool leftButtonDown;
                bool rightButtonDown; 
                RawStylusActions stylusActions = RawStylusActions.None;
                int timestamp;

                // See if we need to deal sending a leave due to this PresentationSource being Deactivated 
                // If not then we just return and do nothing.
                if (e.StagingItem.Input.RoutedEvent == InputManager.InputReportEvent) 
                { 
                    if (_activeMousePlugInCollection == null || _activeMousePlugInCollection.Element == null)
                        return; 

                    InputReportEventArgs input = e.StagingItem.Input as InputReportEventArgs;

                    if (input.Report.Type != InputType.Mouse) 
                        return;
 
                    RawMouseInputReport mouseInputReport = (RawMouseInputReport) input.Report; 

                    if ((mouseInputReport.Actions & RawMouseActions.Deactivate) != RawMouseActions.Deactivate) 
                        return;

                    mouseDevice = _inputManager.Value.PrimaryMouseDevice;
 
                    // Mouse set directly over to null when truly deactivating.
                    if (mouseDevice == null || mouseDevice.DirectlyOver != null) 
                        return; 

                    leftButtonDown = mouseDevice.LeftButton == MouseButtonState.Pressed; 
                    rightButtonDown = mouseDevice.RightButton == MouseButtonState.Pressed;
                    timestamp = mouseInputReport.Timestamp;

                    // Get presentationsource from element. 
                    source = PresentationSource.CriticalFromVisual(_activeMousePlugInCollection.Element as Visual);
                } 
                else 
                {
                    MouseEventArgs mouseEventArgs = e.StagingItem.Input as MouseEventArgs; 
                    mouseDevice = mouseEventArgs.MouseDevice;
                    leftButtonDown = mouseDevice.LeftButton == MouseButtonState.Pressed;
                    rightButtonDown = mouseDevice.RightButton == MouseButtonState.Pressed;
 
                    // Only look at mouse input reports that truly come from a mouse (and is not an up or deactivate) and it
                    // must be pressed state if a move (we don't fire stylus inair moves currently) 
                    if (mouseEventArgs.StylusDevice != null && 
                        e.StagingItem.Input.RoutedEvent != Mouse.PreviewMouseUpEvent)
                        return; 

                    if (e.StagingItem.Input.RoutedEvent == Mouse.PreviewMouseMoveEvent)
                    {
                        if (!leftButtonDown) 
                            return;
                        stylusActions = RawStylusActions.Move; 
                    } 
                    if (e.StagingItem.Input.RoutedEvent == Mouse.PreviewMouseDownEvent)
                    { 
                        MouseButtonEventArgs mouseButtonEventArgs = mouseEventArgs as MouseButtonEventArgs;
                        if (mouseButtonEventArgs.ChangedButton != MouseButton.Left)
                            return;
                        stylusActions = RawStylusActions.Down; 
                    }
                    if (e.StagingItem.Input.RoutedEvent == Mouse.PreviewMouseUpEvent) 
                    { 
                        MouseButtonEventArgs mouseButtonEventArgs = mouseEventArgs as MouseButtonEventArgs;
                        if (mouseButtonEventArgs.ChangedButton != MouseButton.Left) 
                            return;
                        stylusActions = RawStylusActions.Up;
                    }
                    timestamp = mouseEventArgs.Timestamp; 

                    Visual directlyOverVisual = mouseDevice.DirectlyOver as Visual; 
                    if ( directlyOverVisual == null ) 
                    {
                        return; 
                    }

                    // NTRAID:WINDOWSOS#1536432-2006/03/15-WAYNEZEN,
                    // Take the presentation source which is associated to the directly over element. 
                    source = PresentationSource.CriticalFromVisual(directlyOverVisual);
 
                } 

                PenContexts penContexts = GetPenContextsFromHwnd(source); 

                if ((penContexts != null) &&
                    (source != null) &&
                    (source.CompositionTarget != null) && 
                    !source.CompositionTarget.IsDisposed)
                { 
                    IInputElement directlyOver = mouseDevice.DirectlyOver; 
                    int packetStatus = (leftButtonDown ? 1 : 0) | (rightButtonDown ? 9 : 0); // pen tip down == 1, barrel = 8
                    Point ptClient = mouseDevice.GetPosition(source.RootVisual as IInputElement); 
                    ptClient  =  source.CompositionTarget.TransformToDevice.Transform(ptClient);

                    int buttons = (leftButtonDown ? 1 : 0) | (rightButtonDown ? 3 : 0);
                    int [] data = {(int)ptClient.X, (int)ptClient.Y, packetStatus, buttons}; 
                    RawStylusInputReport inputReport = new RawStylusInputReport(
                                                                InputMode.Foreground, 
                                                                timestamp, 
                                                                source,
                                                                stylusActions, 
                                                                GetMousePointDescription,
                                                                data);

                    // Avoid re-entrancy due to lock() being used. 
                    using (Dispatcher.DisableProcessing())
                    { 
                        // Call plugins (does enter/leave and FireCustomData as well) 
                        _activeMousePlugInCollection = penContexts.InvokeStylusPluginCollectionForMouse(inputReport, directlyOver, _activeMousePlugInCollection);
                    } 
                }
            }
        }
Esempio n. 14
0
        private void PromoteMainToOther(ProcessInputEventArgs e)
        { 
            StagingAreaInputItem stagingItem = e.StagingItem; 
            StylusEventArgs stylusEventArgs = stagingItem.Input as StylusEventArgs;
            if (stylusEventArgs == null) 
            {
                return;
            }
            StylusDevice stylusDevice = stylusEventArgs.StylusDevice; 
            StylusTouchDevice touchDevice = stylusDevice.TouchDevice;
            bool shouldPromoteToMouse = ShouldPromoteToMouse(stylusDevice); 
 
            if (IsTouchPromotionEvent(stylusEventArgs))
            { 
                if (e.StagingItem.Input.Handled)
                {
                    // A TouchDevice is activated before TouchDown and deactivated after TouchUp
                    // But if StylusUp event is handled by the user, it will 
                    // never be promoted to TouchUp event leaving the TouchDevice in inconsistent
                    // active state. Hence deactivating touch device if it is active. 
                    if (stylusEventArgs.RoutedEvent == Stylus.StylusUpEvent && 
                        touchDevice.IsActive)
                    { 
                        touchDevice.OnDeactivate();
                    }
                }
                else 
                {
                    // This event is to also route as a Touch event. 
                    // PromoteMainToMouse will eventually see the resulting 
                    // touch event when it finishes and promote to mouse.
                    PromoteMainToTouch(e, stylusEventArgs); 
                }
            }
            else if (e.StagingItem.Input.RoutedEvent == Stylus.StylusSystemGestureEvent)
            { 
                // Promote stylus system gesture to mouse if needed or
                // store them if it cannot be determined that we are manipulating 
                // at this stage. 
                if (shouldPromoteToMouse)
                { 
                    if (touchDevice.PromotingToManipulation)
                    {
                        touchDevice.StoredStagingAreaItems.Add(stagingItem);
                    } 
                    else if (touchDevice.PromotingToOther)
                    { 
                        PromoteMainToMouse(stagingItem); 
                    }
                } 
            }
            else if(shouldPromoteToMouse && touchDevice.PromotingToOther)
            {
                // This is not a touch event, go to mouse 
                PromoteMainToMouse(stagingItem);
            } 
        } 
Esempio n. 15
0
        /// <summary>
        /// The handle input manager post process input.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void HandleInputManagerPostProcessInput(object sender, ProcessInputEventArgs e)
        {
            if (((e.StagingItem == null) || (e.StagingItem.Input == null)) || (!(e.StagingItem.Input.Device is KeyboardDevice)))
            {
                return;
            }

            this.lastMessage = DateTime.Now;
        }
Esempio n. 16
0
        private void PostProcessInput(object sender, ProcessInputEventArgs e)
        {
            // KeyUp
            if (e.StagingItem.Input.RoutedEvent == Keyboard.KeyUpEvent)
            {
                KeyEventArgs keyArgs = (KeyEventArgs)e.StagingItem.Input;
                if (!keyArgs.Handled)
                {
                    if (keyArgs.RealKey == Key.LeftAlt || keyArgs.RealKey == Key.RightAlt)
                    {
                        // Make sure both Alt keys are up.
                        ModifierKeys modifiers = keyArgs.KeyboardDevice.Modifiers;
                        if ((modifiers & ModifierKeys.Alt) == 0)
                        {
                            if (_altNumpadEntryMode)
                            {
                                _altNumpadEntryMode = false;

                                // Generate the Unicode equivalent if we
                                // actually entered a number via the numpad.
                                if (_altNumpadEntry != 0)
                                {
                                    _altNumpadcomposition.ClearTexts();
                                    if (_altNumpadConversionMode == AltNumpadConversionMode.OEMCodePage)
                                    {
                                        _altNumpadcomposition.SetText(GetCurrentOEMCPEncoding(_altNumpadEntry));
                                    }
                                    else if ((_altNumpadConversionMode == AltNumpadConversionMode.DefaultCodePage) ||
                                             (_altNumpadConversionMode == AltNumpadConversionMode.HexDefaultCodePage))
                                    {
                                        _altNumpadcomposition.SetText(CharacterEncoding(InputLanguageManager.Current.CurrentInputLanguage.TextInfo.ANSICodePage, _altNumpadEntry));
                                    }
                                    else if (_altNumpadConversionMode == AltNumpadConversionMode.HexUnicode)
                                    {
                                        Char[] chars = new Char[1];
                                        chars[0] = (Char)_altNumpadEntry;
                                        _altNumpadcomposition.SetText(new string(chars));
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    // Someone handled Alt key up event, we cancel Alt-Numpad handling.
                    _altNumpadEntryMode      = false;
                    _altNumpadEntry          = 0;
                    _altNumpadConversionMode = AltNumpadConversionMode.OEMCodePage;
                }
            }

            // PreviewTextInputBegin --> TextInputStart
            else if (e.StagingItem.Input.RoutedEvent == TextCompositionManager.PreviewTextInputStartEvent)
            {
                TextCompositionEventArgs textArgs = (TextCompositionEventArgs)e.StagingItem.Input;
                if (!textArgs.Handled)
                {
                    TextCompositionEventArgs text = new TextCompositionEventArgs(textArgs.Device, textArgs.TextComposition);
                    text.RoutedEvent = TextCompositionManager.TextInputStartEvent;
                    text.Source      = textArgs.TextComposition.Source;
                    e.PushInput(text, e.StagingItem);
                }
            }

            // PreviewTextInputUpdate --> TextInputUpdate
            else if (e.StagingItem.Input.RoutedEvent == TextCompositionManager.PreviewTextInputUpdateEvent)
            {
                TextCompositionEventArgs textArgs = (TextCompositionEventArgs)e.StagingItem.Input;
                if (!textArgs.Handled)
                {
                    TextCompositionEventArgs text = new TextCompositionEventArgs(textArgs.Device, textArgs.TextComposition);
                    text.RoutedEvent = TextCompositionManager.TextInputUpdateEvent;
                    text.Source      = textArgs.TextComposition.Source;
                    e.PushInput(text, e.StagingItem);
                }
            }

            // PreviewTextInput --> TextInput
            else if (e.StagingItem.Input.RoutedEvent == TextCompositionManager.PreviewTextInputEvent)
            {
                TextCompositionEventArgs textArgs = (TextCompositionEventArgs)e.StagingItem.Input;
                if (!textArgs.Handled)
                {
                    TextCompositionEventArgs text = new TextCompositionEventArgs(textArgs.Device, textArgs.TextComposition);
                    text.RoutedEvent = TextCompositionManager.TextInputEvent;
                    text.Source      = textArgs.TextComposition.Source;
                    e.PushInput(text, e.StagingItem);
                }
            }

            // TextCompositioniBegin --> TextInput if this is AutomaticComplete.
            else if (e.StagingItem.Input.RoutedEvent == TextCompositionManager.TextInputStartEvent)
            {
                TextCompositionEventArgs textArgs = (TextCompositionEventArgs)e.StagingItem.Input;
                if (!textArgs.Handled)
                {
                    if (textArgs.TextComposition.AutoComplete == TextCompositionAutoComplete.On)
                    {
                        textArgs.Handled = UnsafeCompleteComposition(textArgs.TextComposition);
                    }
                }
            }

            // TextCompositionUpdate --> TextInput if this is AutomaticComplete.
            else if (e.StagingItem.Input.RoutedEvent == TextCompositionManager.TextInputUpdateEvent)
            {
                TextCompositionEventArgs textArgs = (TextCompositionEventArgs)e.StagingItem.Input;
                if (!textArgs.Handled)
                {
                    if ((textArgs.TextComposition == _deadCharTextComposition) &&
                        (_deadCharTextComposition.Composed))
                    {
                        //Clear the _deadCharTextComposition to handle re-entrant cases.
                        DeadCharTextComposition comp = _deadCharTextComposition;
                        _deadCharTextComposition = null;
                        textArgs.Handled         = UnsafeCompleteComposition(comp);
                    }
                }
            }


            // Raw to StartComposition.
            InputReportEventArgs input = e.StagingItem.Input as InputReportEventArgs;

            if (input != null)
            {
                if (input.Report.Type == InputType.Text && input.RoutedEvent == InputManager.InputReportEvent)
                {
                    RawTextInputReport textInput;
                    textInput = (RawTextInputReport)input.Report;

                    //
                    //



                    string inputText = new string(textInput.CharacterCode, 1);
                    bool   fDoneAltNumpadComposition = false;

                    if (_altNumpadcomposition != null)
                    {
                        // Generate TextInput event from WM_CHAR handler.
                        if (inputText.Equals(_altNumpadcomposition.Text))
                        {
                            fDoneAltNumpadComposition = true;
                        }
                        else
                        {
                            // The generated text from InputReport does not matched with _altNumpadcomposition.
                            // Cancel this composition and process the char from InputReport.
                            _altNumpadcomposition.ClearTexts();
                        }

                        _altNumpadcomposition.Complete();
                        ClearAltnumpadComposition();
                    }

                    if (!fDoneAltNumpadComposition)
                    {
                        if (textInput.IsDeadCharacter)
                        {
                            _deadCharTextComposition = new DeadCharTextComposition(_inputManager, (IInputElement)null, inputText, TextCompositionAutoComplete.Off, InputManager.Current.PrimaryKeyboardDevice);
                            if (textInput.IsSystemCharacter)
                            {
                                _deadCharTextComposition.MakeSystem();
                            }
                            else if (textInput.IsControlCharacter)
                            {
                                _deadCharTextComposition.MakeControl();
                            }

                            input.Handled = UnsafeStartComposition(_deadCharTextComposition);
                        }
                        else
                        {
                            if (_deadCharTextComposition != null)
                            {
                                input.Handled = CompleteDeadCharComposition(inputText,
                                                                            textInput.IsSystemCharacter,
                                                                            textInput.IsControlCharacter);
                            }
                            else
                            {
                                TextComposition composition = new TextComposition(_inputManager, (IInputElement)e.StagingItem.Input.Source, inputText, TextCompositionAutoComplete.On, InputManager.Current.PrimaryKeyboardDevice);
                                if (textInput.IsSystemCharacter)
                                {
                                    composition.MakeSystem();
                                }
                                else if (textInput.IsControlCharacter)
                                {
                                    composition.MakeControl();
                                }
                                input.Handled = UnsafeStartComposition(composition);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 17
0
 private void PostProcessInput( object sender, ProcessInputEventArgs e )
 {
     if (e.StagingItem.Input.RoutedEvent == InputManager.InputReportEvent)
     {
         if (!e.StagingItem.Input.Handled)
         {
             InputReportEventArgs inputReportEventArgs = e.StagingItem.Input as InputReportEventArgs;
             if (inputReportEventArgs != null)
             {
                 RawAppCommandInputReport rawAppCommandInputReport = inputReportEventArgs.Report as RawAppCommandInputReport;
                 if (rawAppCommandInputReport != null)
                 {
                     IInputElement commandTarget = e.StagingItem.Input.OriginalSource as IInputElement;
                     if (commandTarget != null)
                     {
                         RoutedCommand command = GetRoutedCommand(rawAppCommandInputReport.AppCommand);
                         if (command != null)
                         {
                             // Send the app command to the tree to be handled by UIElements and ContentElements
                             // that will forward the event to CommandManager.
                             CommandDeviceEventArgs args = new CommandDeviceEventArgs(this, rawAppCommandInputReport.Timestamp, command);
                             args.RoutedEvent = CommandDeviceEvent;
                             args.Source = commandTarget;
                             e.PushInput(args, e.StagingItem);
                         }
                     }
                 }
             }
         }
     }
     else if (e.StagingItem.Input.RoutedEvent == Keyboard.KeyUpEvent ||
              e.StagingItem.Input.RoutedEvent == Mouse.MouseUpEvent ||
              e.StagingItem.Input.RoutedEvent == Keyboard.GotKeyboardFocusEvent ||
              e.StagingItem.Input.RoutedEvent == Keyboard.LostKeyboardFocusEvent)
     {
         CommandManager.InvalidateRequerySuggested();
     }
 }
Esempio n. 18
0
		public bool ProcessInput (InputEventArgs input)
		{
			StagingAreaInputItem stagingItem = new StagingAreaInputItem (input);

			PreProcessInputEventArgs preProcessArgs = new PreProcessInputEventArgs(this, stagingItem);
			if (PreProcessInput != null)
				PreProcessInput (this, preProcessArgs);

			NotifyInputEventArgs notifyArgs = new NotifyInputEventArgs(this, stagingItem);
			if (PreNotifyInput != null)
				PreNotifyInput (this, notifyArgs);

#if notyet
			if (!preProcessArgs.Canceled)
				/* XXX route the event */;
#endif

			if (PostNotifyInput != null)
				PostNotifyInput (this, notifyArgs);

			if (PostProcessInput != null) {
				ProcessInputEventArgs processArgs = new ProcessInputEventArgs (this, stagingItem);
				PostProcessInput (this, processArgs);
			}

			return true;
		}
Esempio n. 19
0
        private void PostProcessInput(object sender, ProcessInputEventArgs e)
        { 
            TextServicesContext context;
            KeyEventArgs keyArgs;

            if (!TextServicesLoader.ServicesInstalled) 
                return;
 
            // IMM32-IME handles the key event and we don't do anything. 
            if (InputMethod.IsImm32ImeCurrent())
                return; 

            DependencyObject element = Keyboard.FocusedElement as DependencyObject;
            if ((element == null) || (bool)element.GetValue(InputMethod.IsInputMethodSuspendedProperty))
            { 
                // The focus is on the element that suspending IME's input (such as menu).
                // we don't do anything. 
                return; 
            }
 
            if(e.StagingItem.Input.RoutedEvent == Keyboard.PreviewKeyDownEvent ||
               e.StagingItem.Input.RoutedEvent == Keyboard.PreviewKeyUpEvent)
            {
                // filter SysKey 
                if (IsSysKeyDown())
                    return; 
 
                keyArgs = (KeyEventArgs)e.StagingItem.Input;
 
                if(!keyArgs.Handled && keyArgs.Key == Key.ImeProcessed)
                {
                    context = TextServicesContext.DispatcherCurrent;
 
                    if (context != null)
                    { 
                        if (TextServicesKeystroke(context, keyArgs, false /* test */)) 
                        {
                            keyArgs.Handled = true; 
                        }
                    }
                }
            } 
            else if(e.StagingItem.Input.RoutedEvent == Keyboard.KeyDownEvent ||
                    e.StagingItem.Input.RoutedEvent == Keyboard.KeyUpEvent) 
            { 
                keyArgs = (KeyEventArgs)e.StagingItem.Input;
                if(!keyArgs.Handled && keyArgs.Key == Key.ImeProcessed) 
                {
                    keyArgs.Handled = true;
                }
            } 
        }
Esempio n. 20
0
        private void OnPostProcessInput(object sender, ProcessInputEventArgs e)
        {
            if (e.StagingItem.Input.RoutedEvent == InputManager.InputReportEvent)
            {
                InputReportEventArgs report = (InputReportEventArgs)e.StagingItem.Input;
                if (!report.Handled)
                {
                    if (report.Report.Type == InputType.Mouse)
                    {
                        RawMouseInputReport mouseReport = (RawMouseInputReport)report.Report;
                        if ((mouseReport.Actions & RawMouseActions.AbsoluteMove) == RawMouseActions.AbsoluteMove)
                        {
                            if ((Mouse.LeftButton == MouseButtonState.Pressed) ||
                                (Mouse.RightButton == MouseButtonState.Pressed))
                            {
                                RaiseToolTipClosingEvent(true /* reset */);
                            }
                            else
                            {
                                IInputElement directlyOver = Mouse.PrimaryDevice.RawDirectlyOver;
                                if (directlyOver != null)
                                {
                                    Point pt = Mouse.PrimaryDevice.GetPosition(directlyOver);

                                    // If possible, check that the mouse position is within the render bounds
                                    // (avoids mouse capture confusion).
                                    if (Mouse.CapturedMode != CaptureMode.None)
                                    {
                                        // Get the root visual
                                        PresentationSource source = PresentationSource.CriticalFromVisual((DependencyObject)directlyOver);
                                        UIElement rootAsUIElement = source != null ? source.RootVisual as UIElement : null;
                                        if (rootAsUIElement != null)
                                        {
                                            // Get mouse position wrt to root
                                            pt = Mouse.PrimaryDevice.GetPosition(rootAsUIElement);

                                            // Hittest to find the element the mouse is over
                                            IInputElement enabledHit;
                                            rootAsUIElement.InputHitTest(pt, out enabledHit, out directlyOver);

                                            // Find the position of the mouse relative the element that the mouse is over
                                            pt = Mouse.PrimaryDevice.GetPosition(directlyOver);
                                        }
                                        else
                                        {
                                            directlyOver = null;
                                        }
                                    }

                                    if (directlyOver != null)
                                    {
                                        // Process the mouse move
                                        OnMouseMove(directlyOver, pt);
                                    }
                                }
                            }
                        }
                        else if ((mouseReport.Actions & RawMouseActions.Deactivate) == RawMouseActions.Deactivate)
                        {
                            if (LastMouseDirectlyOver != null)
                            {
                                LastMouseDirectlyOver = null;
                                if (LastMouseOverWithToolTip != null)
                                {
                                    RaiseToolTipClosingEvent(true /* reset */);

                                    // When the user moves the cursor outside of the window,
                                    // clear the LastMouseOverWithToolTip property so if the user returns
                                    // the mouse to the same item, the tooltip will reappear.  If
                                    // the deactivation is coming from a window grabbing capture
                                    // (such as Drag and Drop) do not clear the property.
                                    if (MS.Win32.SafeNativeMethods.GetCapture() == IntPtr.Zero)
                                    {
                                        LastMouseOverWithToolTip = null;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (e.StagingItem.Input.RoutedEvent == Keyboard.KeyDownEvent)
            {
                ProcessKeyDown(sender, (KeyEventArgs)e.StagingItem.Input);
            }
            else if (e.StagingItem.Input.RoutedEvent == Keyboard.KeyUpEvent)
            {
                ProcessKeyUp(sender, (KeyEventArgs)e.StagingItem.Input);
            }
            else if (e.StagingItem.Input.RoutedEvent == Mouse.MouseUpEvent)
            {
                ProcessMouseUp(sender, (MouseButtonEventArgs)e.StagingItem.Input);
            }
            else if (e.StagingItem.Input.RoutedEvent == Mouse.MouseDownEvent)
            {
                RaiseToolTipClosingEvent(true /* reset */);
            }
        }
Esempio n. 21
0
        private void PostProcessInput(object sender, ProcessInputEventArgs e)
        {
            InputEventArgs inputEventArgs = e.StagingItem.Input;
            if ((inputEventArgs != null) && (inputEventArgs.Device == this))
            {
                if (inputEventArgs.Handled)
                {
                    RoutedEvent routedEvent = inputEventArgs.RoutedEvent;

                    if (routedEvent == Touch.PreviewTouchMoveEvent ||
                        routedEvent == Touch.TouchMoveEvent)
                    {
                        _lastMoveHandled = true;
                    }
                    else if (routedEvent == Touch.PreviewTouchDownEvent ||
                        routedEvent == Touch.TouchDownEvent)
                    {
                        _lastDownHandled = true;
                    }
                    else if (routedEvent == Touch.PreviewTouchUpEvent ||
                        routedEvent == Touch.TouchUpEvent)
                    {
                        _lastUpHandled = true;
                    }
                }
                else
                {
                    bool forManipulation;
                    RoutedEvent promotedTouchEvent = PromotePreviewToMain(inputEventArgs.RoutedEvent, out forManipulation);
                    if (promotedTouchEvent != null)
                    {
                        TouchEventArgs promotedTouchEventArgs = CreateEventArgs(promotedTouchEvent);
                        e.PushInput(promotedTouchEventArgs, e.StagingItem);
                    }
                    else if (forManipulation)
                    {
                        UIElement manipulatableElement = GetManipulatableElement();
                        if (manipulatableElement != null)
                        {
                            PromoteMainToManipulation(manipulatableElement, (TouchEventArgs)inputEventArgs);
                        }
                    }
                }
            }
        }
Esempio n. 22
0
		static void PromotePreviewToMain(ProcessInputEventArgs e, InputEventArgs input)
		{
			ContactEventArgs previewArgs = (ContactEventArgs)input;
			RoutedEvent mainEvent = GetMainEventFromPreviewEvent(input.RoutedEvent);
			if (mainEvent != null)
			{
				ContactEventArgs mainArgs;
				if (mainEvent == MultitouchScreen.NewContactEvent || mainEvent == MultitouchScreen.PreviewNewContactEvent)
				{
					NewContactEventArgs newContactEventArgs = (NewContactEventArgs)previewArgs;
					mainArgs = new NewContactEventArgs(newContactEventArgs.Contact, previewArgs.Timestamp);
				}
				else
					mainArgs = new ContactEventArgs(previewArgs.Contact, previewArgs.Timestamp);
				mainArgs.RoutedEvent = mainEvent;
				mainArgs.Source = previewArgs.Source;
				e.PushInput(mainArgs, e.StagingItem);
			}
		}
Esempio n. 23
0
		void PromoteRawToPreview(ProcessInputEventArgs e, RawMultitouchReport report)
		{
			ContactContext context = report.Context;
			RoutedEvent routedEvent = GetPreviewEventFromRawMultitouchState(context.Contact.State);
			if (report.Context.OverElement != null && routedEvent != null)
			{
				Contact contact = ContactsManager.ExistingContacts[report.Context.Contact.Id];
				ContactEventArgs args;
				if (routedEvent == MultitouchScreen.PreviewNewContactEvent)
					args = new NewContactEventArgs(contact, report.Timestamp);
				else
					args = new ContactEventArgs(contact, report.Timestamp);
				args.RoutedEvent = routedEvent;
				args.Source = report.Context.OverElement;
				e.PushInput(args, e.StagingItem);
			}
		}
Esempio n. 24
0
		void inputManager_PostProcessInput(object sender, ProcessInputEventArgs e)
		{
			InputEventArgs input = e.StagingItem.Input;
			if (input.RoutedEvent == PreviewRawInputEvent && !input.Handled)
				PromoteRawToPreview(e, (RawMultitouchReport)input);
			else if (input.Device != null && input.Device.GetType() == contactType)
			{
				if (!input.Handled)
					PromotePreviewToMain(e, input);
				
				if (input.RoutedEvent == MultitouchScreen.ContactRemovedEvent)
				{
					ContactEventArgs args = (ContactEventArgs)input;
					RawMultitouchReport report = args.Contact.InputArgs.Clone();
					report.CleanUp = true;
					e.PushInput(report, e.StagingItem);
				}
			}
		}
 private void InputManager_PostProcessInput(object sender, ProcessInputEventArgs e)
 {
     var inputManager = (InputManager)sender;
     Contract.Assume(inputManager != null);
     IsFocusVisualVisible = SystemParameters.KeyboardCues || (inputManager.MostRecentInputDevice is KeyboardDevice);
 }
Esempio n. 26
0
        private void PostProcessInput(object sender, ProcessInputEventArgs e)
        {
            // KeyUp 
            if(e.StagingItem.Input.RoutedEvent == Keyboard.KeyUpEvent)
            { 
                KeyEventArgs keyArgs = (KeyEventArgs) e.StagingItem.Input; 
                if(!keyArgs.Handled)
                { 
                    if(keyArgs.RealKey == Key.LeftAlt || keyArgs.RealKey == Key.RightAlt)
                    {
                        // Make sure both Alt keys are up.
                        ModifierKeys modifiers = keyArgs.KeyboardDevice.Modifiers; 
                        if((modifiers & ModifierKeys.Alt) == 0)
                        { 
                            if(_altNumpadEntryMode) 
                            {
                                _altNumpadEntryMode = false; 

                                // Generate the Unicode equivalent if we
                                // actually entered a number via the numpad.
                                if(_altNumpadEntry != 0) 
                                {
                                    _altNumpadcomposition.ClearTexts(); 
                                    if (_altNumpadConversionMode == AltNumpadConversionMode.OEMCodePage) 
                                    {
                                        _altNumpadcomposition.SetText(GetCurrentOEMCPEncoding(_altNumpadEntry)); 
                                    }
                                    else if ((_altNumpadConversionMode == AltNumpadConversionMode.DefaultCodePage) ||
                                             (_altNumpadConversionMode == AltNumpadConversionMode.HexDefaultCodePage))
                                    { 
                                        _altNumpadcomposition.SetText(CharacterEncoding(InputLanguageManager.Current.CurrentInputLanguage.TextInfo.ANSICodePage, _altNumpadEntry));
                                    } 
                                    else if (_altNumpadConversionMode == AltNumpadConversionMode.HexUnicode) 
                                    {
                                        Char[] chars = new Char[1]; 
                                        chars[0] = (Char) _altNumpadEntry;
                                        _altNumpadcomposition.SetText(new string(chars));
                                    }
                                } 
                            }
                        } 
                    } 
                }
                else 
                {
                    // Someone handled Alt key up event, we cancel Alt-Numpad handling.
                    _altNumpadEntryMode = false;
                    _altNumpadEntry = 0; 
                    _altNumpadConversionMode = AltNumpadConversionMode.OEMCodePage;
                } 
            } 

            // PreviewTextInputBegin --> TextInputStart 
            else if(e.StagingItem.Input.RoutedEvent == TextCompositionManager.PreviewTextInputStartEvent)
            {
                TextCompositionEventArgs textArgs = (TextCompositionEventArgs) e.StagingItem.Input;
                if(!textArgs.Handled) 
                {
                    TextCompositionEventArgs text = new TextCompositionEventArgs(textArgs.Device, textArgs.TextComposition); 
                    text.RoutedEvent=TextCompositionManager.TextInputStartEvent; 
                    text.Source= textArgs.TextComposition.Source;
                    e.PushInput(text, e.StagingItem); 
                }
            }

            // PreviewTextInputUpdate --> TextInputUpdate 
            else if(e.StagingItem.Input.RoutedEvent == TextCompositionManager.PreviewTextInputUpdateEvent)
            { 
                TextCompositionEventArgs textArgs = (TextCompositionEventArgs) e.StagingItem.Input; 
                if(!textArgs.Handled)
                { 
                    TextCompositionEventArgs text = new TextCompositionEventArgs(textArgs.Device, textArgs.TextComposition);
                    text.RoutedEvent=TextCompositionManager.TextInputUpdateEvent;
                    text.Source= textArgs.TextComposition.Source;
                    e.PushInput(text, e.StagingItem); 
                }
            } 
 
            // PreviewTextInput --> TextInput
            else if(e.StagingItem.Input.RoutedEvent == TextCompositionManager.PreviewTextInputEvent) 
            {
                TextCompositionEventArgs textArgs = (TextCompositionEventArgs) e.StagingItem.Input;
                if(!textArgs.Handled)
                { 
                    TextCompositionEventArgs text = new TextCompositionEventArgs(textArgs.Device, textArgs.TextComposition);
                    text.RoutedEvent=TextCompositionManager.TextInputEvent; 
                    text.Source= textArgs.TextComposition.Source; 
                    e.PushInput(text, e.StagingItem);
                } 
            }

            // TextCompositioniBegin --> TextInput if this is AutomaticComplete.
            else if(e.StagingItem.Input.RoutedEvent == TextCompositionManager.TextInputStartEvent) 
            {
                TextCompositionEventArgs textArgs = (TextCompositionEventArgs) e.StagingItem.Input; 
                if(!textArgs.Handled) 
                {
                    if (textArgs.TextComposition.AutoComplete == TextCompositionAutoComplete.On) 
                    {
                        textArgs.Handled = UnsafeCompleteComposition(textArgs.TextComposition);
                    }
                } 
            }
 
            // TextCompositionUpdate --> TextInput if this is AutomaticComplete. 
            else if(e.StagingItem.Input.RoutedEvent == TextCompositionManager.TextInputUpdateEvent)
            { 
                TextCompositionEventArgs textArgs = (TextCompositionEventArgs) e.StagingItem.Input;
                if(!textArgs.Handled)
                {
                    if ((textArgs.TextComposition == _deadCharTextComposition) && 
                         (_deadCharTextComposition.Composed))
                    { 
                        //Clear the _deadCharTextComposition to handle re-entrant cases. 
                        DeadCharTextComposition comp = _deadCharTextComposition;
                        _deadCharTextComposition = null; 
                        textArgs.Handled = UnsafeCompleteComposition(comp);
                    }
                }
            } 

 
            // Raw to StartComposition. 
            InputReportEventArgs input = e.StagingItem.Input as InputReportEventArgs;
            if(input != null) 
            {
                if(input.Report.Type == InputType.Text && input.RoutedEvent == InputManager.InputReportEvent)
                {
                    RawTextInputReport textInput; 
                    textInput = (RawTextInputReport)input.Report;
 
                    // 
                    //
 


                    string inputText = new string(textInput.CharacterCode, 1);
                    bool fDoneAltNumpadComposition = false; 

                    if (_altNumpadcomposition != null) 
                    { 
                        // Generate TextInput event from WM_CHAR handler.
                        if (inputText.Equals(_altNumpadcomposition.Text)) 
                        {
                            fDoneAltNumpadComposition = true;
                        }
                        else 
                        {
                            // The generated text from InputReport does not matched with _altNumpadcomposition. 
                            // Cancel this composition and process the char from InputReport. 
                            _altNumpadcomposition.ClearTexts();
                        } 

                        _altNumpadcomposition.Complete();
                        ClearAltnumpadComposition();
                    } 

                    if (!fDoneAltNumpadComposition) 
                    { 
                        if (textInput.IsDeadCharacter)
                        { 
                            _deadCharTextComposition = new DeadCharTextComposition(_inputManager, (IInputElement)null, inputText , TextCompositionAutoComplete.Off, InputManager.Current.PrimaryKeyboardDevice);
                            if (textInput.IsSystemCharacter)
                            {
                                _deadCharTextComposition.MakeSystem(); 
                            }
                            else if (textInput.IsControlCharacter) 
                            { 
                                _deadCharTextComposition.MakeControl();
                            } 

                            input.Handled = UnsafeStartComposition(_deadCharTextComposition);
                        }
                        else 
                        {
 
                            if(inputText != null) 
                            {
                                if (_deadCharTextComposition != null) 
                                {
                                    _deadCharTextComposition.ClearTexts();
                                    _deadCharTextComposition.SetText(inputText);
                                    _deadCharTextComposition.Composed = true; 
                                    if (textInput.IsSystemCharacter)
                                    { 
                                        _deadCharTextComposition.MakeSystem(); 
                                    }
                                    else if (textInput.IsControlCharacter) 
                                    {
                                        _deadCharTextComposition.MakeControl();
                                    }
                                    input.Handled = UnsafeUpdateComposition(_deadCharTextComposition); 
                                }
                                else 
                                { 
                                    TextComposition composition = new TextComposition(_inputManager, (IInputElement)e.StagingItem.Input.Source, inputText, TextCompositionAutoComplete.On, InputManager.Current.PrimaryKeyboardDevice);
                                    if (textInput.IsSystemCharacter) 
                                    {
                                        composition.MakeSystem();
                                    }
                                    else if (textInput.IsControlCharacter) 
                                    {
                                        composition.MakeControl(); 
                                    } 
                                    input.Handled = UnsafeStartComposition(composition);
                                } 
                            }
                        }
                    }
                } 
            }
        } 
Esempio n. 27
0
        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;
                    }
                }
            }
        }
Esempio n. 28
0
        private void PostProcessInput(object sender, ProcessInputEventArgs e)
        {
            if (e.StagingItem.Input.Handled) return;

            if (e.StagingItem.Input.RoutedEvent == Keyboard.KeyDownEvent)
            {
                OnKeyDown((KeyEventArgs)e.StagingItem.Input);
            }
            else if (e.StagingItem.Input.RoutedEvent == TextCompositionManager.TextInputEvent)
            {
                OnText((TextCompositionEventArgs)e.StagingItem.Input);
            }
            
        }
Esempio n. 29
0
 void PromoteRawToPreview(RawStylusInputReport report, ProcessInputEventArgs e)
 {
     RoutedEvent routedEvent = GetPreviewEventFromRawStylusActions(report.Actions); 
     if (routedEvent != null && report.StylusDevice != null && !report.StylusDevice.IgnoreStroke)
     { 
         StylusEventArgs args; 
         if (routedEvent != Stylus.PreviewStylusSystemGestureEvent)
         { 
             if (routedEvent == Stylus.PreviewStylusDownEvent)
             {
                 args = new StylusDownEventArgs(report.StylusDevice, report.Timestamp);
             } 
             else
             { 
                 args = new StylusEventArgs(report.StylusDevice, report.Timestamp); 
              }
         } 
         else
         {
             RawStylusSystemGestureInputReport reportSg = (RawStylusSystemGestureInputReport)report;
             args = new StylusSystemGestureEventArgs(report.StylusDevice, 
                                                     report.Timestamp,
                                                     reportSg.SystemGesture, 
                                                     reportSg.GestureX, 
                                                     reportSg.GestureY,
                                                     reportSg.ButtonState); 
         }
         args.InputReport = report;
         args.RoutedEvent= routedEvent;
         e.PushInput(args, e.StagingItem); 
     }
 } 
Esempio n. 30
0
        private void UpdateButtonStates(ProcessInputEventArgs e)
        { 
            if (!e.StagingItem.Input.Handled) 
            {
                RoutedEvent routedEvent = e.StagingItem.Input.RoutedEvent; 
                if (routedEvent != null && (routedEvent == Stylus.StylusDownEvent
                                     || routedEvent == Stylus.StylusUpEvent
                                     || routedEvent == Stylus.StylusMoveEvent
                                     || routedEvent == Stylus.StylusInAirMoveEvent)) 
                {
                    StylusEventArgs eventArgs = (StylusEventArgs)e.StagingItem.Input; 
                    RawStylusInputReport report = eventArgs.InputReport; 

                    StylusDevice stylusDevice = report.StylusDevice; 
                    System.Diagnostics.Debug.Assert(stylusDevice != null);

                    StylusPointCollection stylusPoints = stylusDevice.GetStylusPoints(null);
                    StylusPoint stylusPoint = stylusPoints[stylusPoints.Count - 1]; 

                    foreach (StylusButton button in stylusDevice.StylusButtons) 
                    { 

                        // ISSUE-2005/2/2-XIAOTU what if more than one button state in a single packet? 
                        // Split the packets or only use the last one as we did below?

                        StylusButtonState currentButtonState =
                            (StylusButtonState)stylusPoint.GetPropertyValue(new StylusPointProperty(button.Guid, true)); 

                        if (currentButtonState != button.CachedButtonState) 
                        { 
                           button.CachedButtonState = currentButtonState;
 
                           // do work to push Button event
                           StylusButtonEventArgs args = new StylusButtonEventArgs(stylusDevice, report.Timestamp, button);
                           args.InputReport = report;
                           if (currentButtonState == StylusButtonState.Down) 
                           {
                               args.RoutedEvent=Stylus.PreviewStylusButtonDownEvent; 
                           } 
                           else
                           { 
                               args.RoutedEvent=Stylus.PreviewStylusButtonUpEvent;
                           }

                           // Process this directly instead of doing a push. We want this event to get 
                           // to the user before the promoted mouse event.
                           InputManagerProcessInputEventArgs(args); 
                        } 
                    }
                } 
            }
        }
Esempio n. 31
0
        private void PostProcessInput(object sender, ProcessInputEventArgs e)
        {
            // PreviewMouseWheel --> MouseWheel
            if (e.StagingItem.Input.RoutedEvent == Mouse.PreviewMouseWheelEvent)
            {
                if (!e.StagingItem.Input.Handled)
                {
                    MouseWheelEventArgs previewWheel = (MouseWheelEventArgs) e.StagingItem.Input;
                    MouseWheelEventArgs wheel = new MouseWheelEventArgs(this, previewWheel.Timestamp, previewWheel.Delta);
                    wheel.RoutedEvent=Mouse.MouseWheelEvent;

                    #if SEND_WHEEL_EVENTS_TO_FOCUS
                    // wheel events are treated as if they came from the
                    // element with keyboard focus
                    wheel.Source = previewWheel.Source;
                    #endif

                    e.PushInput(wheel, e.StagingItem);
                }
            }

            // PreviewMouseDown --> MouseDown
            if (e.StagingItem.Input.RoutedEvent == Mouse.PreviewMouseDownEvent)
            {
                if (!e.StagingItem.Input.Handled)
                {
                    MouseButtonEventArgs previewDown = (MouseButtonEventArgs) e.StagingItem.Input;
                    MouseButtonEventArgs down = new MouseButtonEventArgs(this, previewDown.Timestamp, previewDown.ChangedButton, GetStylusDevice(e.StagingItem));
                    down.ClickCount = previewDown.ClickCount;
                    down.RoutedEvent=Mouse.MouseDownEvent;
                    e.PushInput(down, e.StagingItem);
                }
            }

            // PreviewMouseUp --> MouseUp
            if (e.StagingItem.Input.RoutedEvent == Mouse.PreviewMouseUpEvent)
            {
                if (!e.StagingItem.Input.Handled)
                {
                    MouseButtonEventArgs previewUp = (MouseButtonEventArgs) e.StagingItem.Input;
                    MouseButtonEventArgs up = new MouseButtonEventArgs(this, previewUp.Timestamp, previewUp.ChangedButton, GetStylusDevice(e.StagingItem));
                    up.RoutedEvent=Mouse.MouseUpEvent;
                    e.PushInput(up, e.StagingItem);
                }
            }

            // PreviewMouseMove --> MouseMove
            if (e.StagingItem.Input.RoutedEvent == Mouse.PreviewMouseMoveEvent)
            {
                if (!e.StagingItem.Input.Handled)
                {
                    MouseEventArgs previewMove = (MouseEventArgs) e.StagingItem.Input;
                    MouseEventArgs move = new MouseEventArgs(this, previewMove.Timestamp, GetStylusDevice(e.StagingItem));
                    move.RoutedEvent=Mouse.MouseMoveEvent;
                    e.PushInput(move, e.StagingItem);
                }
            }

            // We are finished processing the QueryCursor event.  Just update the
            // mouse cursor to be what was decided during the event route.
            if (e.StagingItem.Input.RoutedEvent == Mouse.QueryCursorEvent)
            {

                QueryCursorEventArgs queryCursor = (QueryCursorEventArgs)e.StagingItem.Input;


                SetCursor(queryCursor.Cursor);

            }

            if (e.StagingItem.Input.RoutedEvent == InputManager.InputReportEvent)
            {
                InputReportEventArgs inputReportEventArgs = e.StagingItem.Input as InputReportEventArgs;

                if (!inputReportEventArgs.Handled && inputReportEventArgs.Report.Type == InputType.Mouse)
                {
                    RawMouseInputReport rawMouseInputReport = (RawMouseInputReport) inputReportEventArgs.Report;

                    // Only process mouse input that is from our active visual manager.
                    if ((_inputSource != null) && (rawMouseInputReport.InputSource == _inputSource.Value))
                    {
                        // In general, this is where we promote the non-redundant
                        // reported actions to our premier events.
                        RawMouseActions actions = GetNonRedundantActions(e);

                        // Raw Activate --> Raw MouseMove
                        // Whenever the mouse device is activated we need to
                        // cause a mouse move so that elements realize that
                        // the mouse is over them again.  In most cases, the
                        // action that caused the mouse to activate is a move,
                        // but this is to guard against any other cases.
                        if ((actions & RawMouseActions.Activate) == RawMouseActions.Activate)
                        {
                            Synchronize();
                        }

                        // Raw --> PreviewMouseWheel
                        if ((actions & RawMouseActions.VerticalWheelRotate) == RawMouseActions.VerticalWheelRotate) // 
                        {
                            MouseWheelEventArgs previewWheel = new MouseWheelEventArgs(this, rawMouseInputReport.Timestamp, rawMouseInputReport.Wheel);

                            previewWheel.RoutedEvent=Mouse.PreviewMouseWheelEvent;

                            #if SEND_WHEEL_EVENTS_TO_FOCUS
                            // wheel events are treated as if they came from the
                            // element with keyboard focus
                            DependencyObject focus = Keyboard.FocusedElement as DependencyObject;
                            if (focus != null)
                            {
                                previewWheel.Source = focus;
                            }
                            #endif

                            e.PushInput(previewWheel, e.StagingItem);
                        }

                        // Raw --> PreviewMouseDown
                        if ((actions & RawMouseActions.Button1Press) == RawMouseActions.Button1Press)
                        {
                            MouseButtonEventArgs previewDown = new MouseButtonEventArgs(this, rawMouseInputReport.Timestamp, MouseButton.Left, GetStylusDevice(e.StagingItem));

                            previewDown.RoutedEvent=Mouse.PreviewMouseDownEvent;
                            e.PushInput(previewDown, e.StagingItem);
                        }

                        // Raw --> PreviewMouseUp
                        if ((actions & RawMouseActions.Button1Release) == RawMouseActions.Button1Release)
                        {
                            MouseButtonEventArgs previewUp = new MouseButtonEventArgs(this, rawMouseInputReport.Timestamp, MouseButton.Left, GetStylusDevice(e.StagingItem));

                            previewUp.RoutedEvent=Mouse.PreviewMouseUpEvent;
                            e.PushInput(previewUp, e.StagingItem);
                        }

                        // Raw --> PreviewMouseDown
                        if ((actions & RawMouseActions.Button2Press) == RawMouseActions.Button2Press)
                        {
                            MouseButtonEventArgs previewDown = new MouseButtonEventArgs(this, rawMouseInputReport.Timestamp, MouseButton.Right, GetStylusDevice(e.StagingItem));

                            previewDown.RoutedEvent=Mouse.PreviewMouseDownEvent;
                            e.PushInput(previewDown, e.StagingItem);
                        }

                        // Raw --> PreviewMouseUp
                        if ((actions & RawMouseActions.Button2Release) == RawMouseActions.Button2Release)
                        {
                            MouseButtonEventArgs previewUp = new MouseButtonEventArgs(this, rawMouseInputReport.Timestamp, MouseButton.Right, GetStylusDevice(e.StagingItem));

                            previewUp.RoutedEvent=Mouse.PreviewMouseUpEvent;
                            e.PushInput(previewUp, e.StagingItem);
                        }

                        // Raw --> PreviewMouseDown
                        if ((actions & RawMouseActions.Button3Press) == RawMouseActions.Button3Press)
                        {
                            MouseButtonEventArgs previewDown = new MouseButtonEventArgs(this, rawMouseInputReport.Timestamp, MouseButton.Middle, GetStylusDevice(e.StagingItem));

                            previewDown.RoutedEvent=Mouse.PreviewMouseDownEvent;
                            e.PushInput(previewDown, e.StagingItem);
                        }

                        // Raw --> PreviewMouseUp
                        if ((actions & RawMouseActions.Button3Release) == RawMouseActions.Button3Release)
                        {
                            MouseButtonEventArgs previewUp = new MouseButtonEventArgs(this, rawMouseInputReport.Timestamp, MouseButton.Middle, GetStylusDevice(e.StagingItem));

                            previewUp.RoutedEvent=Mouse.PreviewMouseUpEvent;
                            e.PushInput(previewUp, e.StagingItem);
                        }

                        // Raw --> PreviewMouseDown
                        if ((actions & RawMouseActions.Button4Press) == RawMouseActions.Button4Press)
                        {
                            MouseButtonEventArgs previewDown = new MouseButtonEventArgs(this, rawMouseInputReport.Timestamp, MouseButton.XButton1, GetStylusDevice(e.StagingItem));

                            previewDown.RoutedEvent=Mouse.PreviewMouseDownEvent;
                            e.PushInput(previewDown, e.StagingItem);
                        }

                        // Raw --> PreviewMouseUp
                        if ((actions & RawMouseActions.Button4Release) == RawMouseActions.Button4Release)
                        {
                            MouseButtonEventArgs previewUp = new MouseButtonEventArgs(this, rawMouseInputReport.Timestamp, MouseButton.XButton1, GetStylusDevice(e.StagingItem));

                            previewUp.RoutedEvent=Mouse.PreviewMouseUpEvent;
                            e.PushInput(previewUp, e.StagingItem);
                        }

                        // Raw --> PreviewMouseDown
                        if ((actions & RawMouseActions.Button5Press) == RawMouseActions.Button5Press)
                        {
                            MouseButtonEventArgs previewDown = new MouseButtonEventArgs(this, rawMouseInputReport.Timestamp, MouseButton.XButton2, GetStylusDevice(e.StagingItem));

                            previewDown.RoutedEvent=Mouse.PreviewMouseDownEvent;
                            e.PushInput(previewDown, e.StagingItem);
                        }

                        // Raw --> PreviewMouseUp
                        if ((actions & RawMouseActions.Button5Release) == RawMouseActions.Button5Release)
                        {
                            MouseButtonEventArgs previewUp = new MouseButtonEventArgs(this, rawMouseInputReport.Timestamp, MouseButton.XButton2, GetStylusDevice(e.StagingItem));

                            previewUp.RoutedEvent=Mouse.PreviewMouseUpEvent;
                            e.PushInput(previewUp, e.StagingItem);
                        }

                        // Raw --> PreviewMouseMove
                        if ((actions & RawMouseActions.AbsoluteMove) == RawMouseActions.AbsoluteMove) // 
                        {
                            MouseEventArgs previewMove = new MouseEventArgs(this, rawMouseInputReport.Timestamp, GetStylusDevice(e.StagingItem));

                            previewMove.RoutedEvent=Mouse.PreviewMouseMoveEvent;
                            e.PushInput(previewMove, e.StagingItem);
                        }

                        // Raw --> QueryCursor
                        if ((actions & RawMouseActions.QueryCursor) == RawMouseActions.QueryCursor)
                        {
                            inputReportEventArgs.Handled = UpdateCursorPrivate();
                        }
                    }
                }
            }
        }
Esempio n. 32
0
        private void PostProcessInput(object sender, ProcessInputEventArgs e)
        {
            // PreviewKeyDown --> KeyDown
            if (e.StagingItem.Input.RoutedEvent == Keyboard.PreviewKeyDownEvent)
            {
                CheckForDisconnectedFocus();

                if (!e.StagingItem.Input.Handled)
                {
                    KeyEventArgs previewKeyDown = (KeyEventArgs)e.StagingItem.Input;

                    // Dig out the real key.
                    bool isSystemKey         = false;
                    bool isImeProcessed      = false;
                    bool isDeadCharProcessed = false;
                    Key  key = previewKeyDown.Key;
                    if (key == Key.System)
                    {
                        isSystemKey = true;
                        key         = previewKeyDown.RealKey;
                    }
                    else if (key == Key.ImeProcessed)
                    {
                        isImeProcessed = true;
                        key            = previewKeyDown.RealKey;
                    }
                    else if (key == Key.DeadCharProcessed)
                    {
                        isDeadCharProcessed = true;
                        key = previewKeyDown.RealKey;
                    }

                    KeyEventArgs keyDown = new KeyEventArgs(this, previewKeyDown.UnsafeInputSource, previewKeyDown.Timestamp, key);
                    keyDown.SetRepeat(previewKeyDown.IsRepeat);

                    // Mark the new event as SystemKey as appropriate.
                    if (isSystemKey)
                    {
                        keyDown.MarkSystem();
                    }
                    else if (isImeProcessed)
                    {
                        // Mark the new event as ImeProcessed as appropriate.
                        keyDown.MarkImeProcessed();
                    }
                    else if (isDeadCharProcessed)
                    {
                        keyDown.MarkDeadCharProcessed();
                    }

                    keyDown.RoutedEvent   = Keyboard.KeyDownEvent;
                    keyDown.ScanCode      = previewKeyDown.ScanCode;
                    keyDown.IsExtendedKey = previewKeyDown.IsExtendedKey;
                    e.PushInput(keyDown, e.StagingItem);
                }
            }

            // PreviewKeyUp --> KeyUp
            if (e.StagingItem.Input.RoutedEvent == Keyboard.PreviewKeyUpEvent)
            {
                CheckForDisconnectedFocus();

                if (!e.StagingItem.Input.Handled)
                {
                    KeyEventArgs previewKeyUp = (KeyEventArgs)e.StagingItem.Input;

                    // Dig out the real key.
                    bool isSystemKey         = false;
                    bool isImeProcessed      = false;
                    bool isDeadCharProcessed = false;
                    Key  key = previewKeyUp.Key;
                    if (key == Key.System)
                    {
                        isSystemKey = true;
                        key         = previewKeyUp.RealKey;
                    }
                    else if (key == Key.ImeProcessed)
                    {
                        isImeProcessed = true;
                        key            = previewKeyUp.RealKey;
                    }
                    else if (key == Key.DeadCharProcessed)
                    {
                        isDeadCharProcessed = true;
                        key = previewKeyUp.RealKey;
                    }

                    KeyEventArgs keyUp = new KeyEventArgs(this, previewKeyUp.UnsafeInputSource, previewKeyUp.Timestamp, key);

                    // Mark the new event as SystemKey as appropriate.
                    if (isSystemKey)
                    {
                        keyUp.MarkSystem();
                    }
                    else if (isImeProcessed)
                    {
                        // Mark the new event as ImeProcessed as appropriate.
                        keyUp.MarkImeProcessed();
                    }
                    else if (isDeadCharProcessed)
                    {
                        keyUp.MarkDeadCharProcessed();
                    }

                    keyUp.RoutedEvent   = Keyboard.KeyUpEvent;
                    keyUp.ScanCode      = previewKeyUp.ScanCode;
                    keyUp.IsExtendedKey = previewKeyUp.IsExtendedKey;
                    e.PushInput(keyUp, e.StagingItem);
                }
            }

            RawKeyboardInputReport keyboardInput = ExtractRawKeyboardInputReport(e, InputManager.InputReportEvent);

            if (keyboardInput != null)
            {
                CheckForDisconnectedFocus();

                if (!e.StagingItem.Input.Handled)
                {
                    // In general, this is where we promote the non-redundant
                    // reported actions to our premier events.
                    RawKeyboardActions actions = GetNonRedundantActions(e);

                    // Raw --> PreviewKeyDown
                    if ((actions & RawKeyboardActions.KeyDown) == RawKeyboardActions.KeyDown)
                    {
                        Key key = (Key)e.StagingItem.GetData(_tagKey);
                        if (key != Key.None)
                        {
                            KeyEventArgs previewKeyDown = new KeyEventArgs(this, keyboardInput.InputSource, keyboardInput.Timestamp, key);
                            ScanCode     scanCode       = (ScanCode)e.StagingItem.GetData(_tagScanCode);
                            previewKeyDown.ScanCode      = scanCode.Code;
                            previewKeyDown.IsExtendedKey = scanCode.IsExtended;
                            if (keyboardInput.IsSystemKey)
                            {
                                previewKeyDown.MarkSystem();
                            }
                            previewKeyDown.RoutedEvent = Keyboard.PreviewKeyDownEvent;
                            e.PushInput(previewKeyDown, e.StagingItem);
                        }
                    }

                    // Raw --> PreviewKeyUp
                    if ((actions & RawKeyboardActions.KeyUp) == RawKeyboardActions.KeyUp)
                    {
                        Key key = (Key)e.StagingItem.GetData(_tagKey);
                        if (key != Key.None)
                        {
                            KeyEventArgs previewKeyUp = new KeyEventArgs(this, keyboardInput.InputSource, keyboardInput.Timestamp, key);
                            ScanCode     scanCode     = (ScanCode)e.StagingItem.GetData(_tagScanCode);
                            previewKeyUp.ScanCode      = scanCode.Code;
                            previewKeyUp.IsExtendedKey = scanCode.IsExtended;
                            if (keyboardInput.IsSystemKey)
                            {
                                previewKeyUp.MarkSystem();
                            }
                            previewKeyUp.RoutedEvent = Keyboard.PreviewKeyUpEvent;
                            e.PushInput(previewKeyUp, e.StagingItem);
                        }
                    }
                }

                // Deactivate
                if ((keyboardInput.Actions & RawKeyboardActions.Deactivate) == RawKeyboardActions.Deactivate)
                {
                    if (IsActive)
                    {
                        _activeSource = null;

                        // Even if handled, a keyboard deactivate results in a lost focus.
                        ChangeFocus(null, e.StagingItem.Input.Timestamp);
                    }
                }
            }
        }
Esempio n. 33
0
 private void PostProcessInput(object sender, ProcessInputEventArgs e)
 {
     // Call Forwarded
     ProcessInput(e.StagingItem.Input);
 }
Esempio n. 34
0
        private void PromoteMainToTouch(ProcessInputEventArgs e, StylusEventArgs stylusEventArgs)
        {
            StylusDevice stylusDevice = stylusEventArgs.StylusDevice;
            stylusDevice.UpdateTouchActiveSource(); 

            if (stylusEventArgs.RoutedEvent == Stylus.StylusMoveEvent) 
            { 
                PromoteMainMoveToTouch(stylusDevice, e.StagingItem);
            } 
            else if (stylusEventArgs.RoutedEvent == Stylus.StylusDownEvent)
            {
                PromoteMainDownToTouch(stylusDevice, e.StagingItem);
            } 
            else if (stylusEventArgs.RoutedEvent == Stylus.StylusUpEvent)
            { 
                PromoteMainUpToTouch(stylusDevice, e.StagingItem); 
            }
        } 
 private void OnPreProcess(object sender, ProcessInputEventArgs e)
 {
     if (e.StagingItem.Input is KeyboardEventArgs ||
         e.StagingItem.Input is MouseEventArgs ||
         e.StagingItem.Input is TouchEventArgs)
     {
         _lastAppicationInputActivity = DateTime.Now;
     }
 }
Esempio n. 36
0
        private void RaiseProcessInputEventHandlers(ProcessInputEventHandler postProcessInput, ProcessInputEventArgs processInputEventArgs)
        {
            processInputEventArgs.StagingItem.Input.MarkAsUserInitiated();

            try
            {
                // Invoke the handlers in reverse order so that handlers that
                // users add are invoked before handlers in the system.
                Delegate[] handlers = postProcessInput.GetInvocationList();
                for(int i = (handlers.Length - 1); i >= 0; i--)
                {
                    ProcessInputEventHandler handler = (ProcessInputEventHandler) handlers[i];
                    handler(this, processInputEventArgs);
                }
            }
            finally // we do this in a finally block in case of exceptions
            {
                processInputEventArgs.StagingItem.Input.ClearUserInitiated();
            }
        }
Esempio n. 37
0
        void PostProcessInput(object sender, ProcessInputEventArgs e)
        {
            MotionTrackingEventArgs input = e.StagingItem.Input as MotionTrackingEventArgs;
            if (input == null || input.Device != this)
                return;

            if (!this.ShouldPromoteToTouch)
            {
                if (lastEventPromoted)
                {
                    PromoteToTouchUp();
                }
                lastEventPromoted = false;
            }
            else
            {
                if (input.RoutedEvent == MotionTracking.MotionTrackingLostEvent)
                {
                    PromoteToTouchUp();
                }
                else
                {
                    PromoteToTouchMove();
                }
                lastEventPromoted = true;
            }
        }
Esempio n. 38
0
        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.

                // In the future, in ordre to
                // make sure we all agree on this.  We could also
                // just delay the rest of the staging area until
                // the dispatcher frame finishes.  Unfortunately,
                // this means one could receive an input event for
                // something that happened a long time ago.
                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);
        }
Esempio n. 39
0
 void PostProcessInput(object sender, ProcessInputEventArgs e)
 {
     if (e.StagingItem.Input.RoutedEvent == Keyboard.KeyDownEvent)
     {
         KeyEventArgs keyArgs = (KeyEventArgs)e.StagingItem.Input;
         if (!keyArgs.Handled && IsKeyTipKey(keyArgs) && State == KeyTipState.None)
         {
             OnKeyTipKeyDown(keyArgs);
         }
         else if (State != KeyTipState.None)
         {
             if (keyArgs.Key == Key.Escape)
             {
                 OnEscapeKeyDown(keyArgs);
             }
         }
     }
 }
Esempio n. 40
0
        private void PostProcessInput(object sender, ProcessInputEventArgs e) 
        {
            // PreviewKeyDown --> KeyDown 
            if(e.StagingItem.Input.RoutedEvent == Keyboard.PreviewKeyDownEvent)
            {
                CheckForDisconnectedFocus();
 
                if(!e.StagingItem.Input.Handled)
                { 
                    KeyEventArgs previewKeyDown = (KeyEventArgs) e.StagingItem.Input; 

                    // Dig out the real key. 
                    bool isSystemKey = false;
                    bool isImeProcessed = false;
                    bool isDeadCharProcessed = false;
                    Key key = previewKeyDown.Key; 
                    if (key == Key.System)
                    { 
                        isSystemKey = true; 
                        key = previewKeyDown.RealKey;
                    } 
                    else if (key == Key.ImeProcessed)
                    {
                        isImeProcessed = true;
                        key = previewKeyDown.RealKey; 
                    }
                    else if (key == Key.DeadCharProcessed) 
                    { 
                        isDeadCharProcessed = true;
                        key = previewKeyDown.RealKey; 
                    }

                    KeyEventArgs keyDown = new KeyEventArgs(this, previewKeyDown.UnsafeInputSource, previewKeyDown.Timestamp, key);
                    keyDown.SetRepeat( previewKeyDown.IsRepeat ); 

                    // Mark the new event as SystemKey as appropriate. 
                    if (isSystemKey) 
                    {
                        keyDown.MarkSystem(); 
                    }
                    else if (isImeProcessed)
                    {
                        // Mark the new event as ImeProcessed as appropriate. 
                        keyDown.MarkImeProcessed();
                    } 
                    else if (isDeadCharProcessed) 
                    {
                        keyDown.MarkDeadCharProcessed(); 
                    }

                    keyDown.RoutedEvent=Keyboard.KeyDownEvent;
                    keyDown.ScanCode = previewKeyDown.ScanCode; 
                    keyDown.IsExtendedKey = previewKeyDown.IsExtendedKey;
                    e.PushInput(keyDown, e.StagingItem); 
                } 
            }
 
            // PreviewKeyUp --> KeyUp
            if(e.StagingItem.Input.RoutedEvent == Keyboard.PreviewKeyUpEvent)
            {
                CheckForDisconnectedFocus(); 

                if(!e.StagingItem.Input.Handled) 
                { 
                    KeyEventArgs previewKeyUp = (KeyEventArgs) e.StagingItem.Input;
 
                    // Dig out the real key.
                    bool isSystemKey = false;
                    bool isImeProcessed = false;
                    bool isDeadCharProcessed = false; 
                    Key key = previewKeyUp.Key;
                    if (key == Key.System) 
                    { 
                        isSystemKey = true;
                        key = previewKeyUp.RealKey; 
                    }
                    else if (key == Key.ImeProcessed)
                    {
                        isImeProcessed = true; 
                        key = previewKeyUp.RealKey;
                    } 
                    else if(key == Key.DeadCharProcessed) 
                    {
                        isDeadCharProcessed = true; 
                        key = previewKeyUp.RealKey;
                    }

                    KeyEventArgs keyUp = new KeyEventArgs(this, previewKeyUp.UnsafeInputSource, previewKeyUp.Timestamp, key); 

                    // Mark the new event as SystemKey as appropriate. 
                    if (isSystemKey) 
                    {
                        keyUp.MarkSystem(); 
                    }
                    else if (isImeProcessed)
                    {
                        // Mark the new event as ImeProcessed as appropriate. 
                        keyUp.MarkImeProcessed();
                    } 
                    else if (isDeadCharProcessed) 
                    {
                        keyUp.MarkDeadCharProcessed(); 
                    }

                    keyUp.RoutedEvent=Keyboard.KeyUpEvent;
                    keyUp.ScanCode = previewKeyUp.ScanCode; 
                    keyUp.IsExtendedKey = previewKeyUp.IsExtendedKey;
                    e.PushInput(keyUp, e.StagingItem); 
                } 
            }
 
            RawKeyboardInputReport keyboardInput = ExtractRawKeyboardInputReport(e, InputManager.InputReportEvent);
            if(keyboardInput != null)
            {
                CheckForDisconnectedFocus(); 

                if(!e.StagingItem.Input.Handled) 
                { 
                    // In general, this is where we promote the non-redundant
                    // reported actions to our premier events. 
                    RawKeyboardActions actions = GetNonRedundantActions(e);

                    // Raw --> PreviewKeyDown
                    if((actions & RawKeyboardActions.KeyDown) == RawKeyboardActions.KeyDown) 
                    {
                        Key key = (Key) e.StagingItem.GetData(_tagKey); 
                        if(key != Key.None) 
                        {
                            KeyEventArgs previewKeyDown = new KeyEventArgs(this, keyboardInput.InputSource, keyboardInput.Timestamp, key); 
                            ScanCode scanCode = (ScanCode)e.StagingItem.GetData(_tagScanCode);
                            previewKeyDown.ScanCode = scanCode.Code;
                            previewKeyDown.IsExtendedKey = scanCode.IsExtended;
                            if (keyboardInput.IsSystemKey) 
                            {
                                previewKeyDown.MarkSystem(); 
                            } 
                            previewKeyDown.RoutedEvent=Keyboard.PreviewKeyDownEvent;
                            e.PushInput(previewKeyDown, e.StagingItem); 
                        }
                    }

                    // Raw --> PreviewKeyUp 
                    if((actions & RawKeyboardActions.KeyUp) == RawKeyboardActions.KeyUp)
                    { 
                        Key key = (Key) e.StagingItem.GetData(_tagKey); 
                        if(key != Key.None)
                        { 
                            KeyEventArgs previewKeyUp = new KeyEventArgs(this, keyboardInput.InputSource, keyboardInput.Timestamp, key);
                            ScanCode scanCode = (ScanCode)e.StagingItem.GetData(_tagScanCode);
                            previewKeyUp.ScanCode = scanCode.Code;
                            previewKeyUp.IsExtendedKey = scanCode.IsExtended; 
                            if (keyboardInput.IsSystemKey)
                            { 
                                previewKeyUp.MarkSystem(); 
                            }
                            previewKeyUp.RoutedEvent=Keyboard.PreviewKeyUpEvent; 
                            e.PushInput(previewKeyUp, e.StagingItem);
                        }
                    }
                } 

                // Deactivate 
                if((keyboardInput.Actions & RawKeyboardActions.Deactivate) == RawKeyboardActions.Deactivate) 
                {
                    if(IsActive) 
                    {
                        _activeSource = null;

                        // Even if handled, a keyboard deactivate results in a lost focus. 
                        ChangeFocus(null, e.StagingItem.Input.Timestamp);
                    } 
                } 
            }
        } 
Esempio n. 41
0
        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;
                    }
                }
            }
        }