internal RawStylusSystemGestureInputReport(
            InputMode mode,
            int timestamp,
            PresentationSource inputSource,
            PenContext penContext,
            int tabletId,
            int stylusDeviceId,
            SystemGesture systemGesture,
            int gestureX,
            int gestureY,
            int buttonState)
            : base(mode, timestamp, inputSource,
                   penContext, RawStylusActions.SystemGesture,
                   tabletId, stylusDeviceId, new int[] {})
        {
            if (!RawStylusSystemGestureInputReport.IsValidSystemGesture(systemGesture, true, true))
            {
                throw new InvalidEnumArgumentException(SR.Get(SRID.Enum_Invalid, "systemGesture"));
            }

            _id          = systemGesture;
            _gestureX    = gestureX;
            _gestureY    = gestureY;
            _buttonState = buttonState;
        }
        private void OnSystemGesture(RawStylusSystemGestureInputReport stylusInputReport)
        {
            switch (_currentState)
            {
            case State.TwoFingersDown:
                switch (stylusInputReport.SystemGesture)
                {
                case SystemGesture.Drag:
                case SystemGesture.RightDrag:
                case SystemGesture.Flick:
                    // One of the two fingers made a Wisptis detected gesture
                    // that prevents TwoFingerTap or Rollover.
                    _currentState = State.TwoFingersInWisptisGesture;
                    break;
                }
                break;

            case State.OneFingerInStaticGesture:
            case State.OneFingerDown:
                switch (stylusInputReport.SystemGesture)
                {
                case SystemGesture.Drag:
                case SystemGesture.RightDrag:
                case SystemGesture.Flick:
                    // A finger made a Wisptis detected gesture
                    // that prevents TwoFingerTap or Rollover.
                    _currentState = State.OneFingerInWisptisGesture;
                    break;
                }
                break;
            }
        }
Example #3
0
        private void Initialize(SystemGesture systemGesture, int gestureX, int gestureY, int buttonState)
        {
            if (!RawStylusSystemGestureInputReport.IsValidSystemGesture(systemGesture, true, true))
            {
                throw new InvalidEnumArgumentException(SR.Get(SRID.Enum_Invalid, nameof(systemGesture)));
            }

            _id          = systemGesture;
            _gestureX    = gestureX;
            _gestureY    = gestureY;
            _buttonState = buttonState;
        }
        /////////////////////////////////////////////////////////////////////
        /// <summary>
        ///     Initializes a new instance of the StylusSystemGestureEventArgs class.
        /// </summary>
        /// <param name="stylusDevice">
        ///     The logical Stylus device associated with this event.
        /// </param>
        /// <param name="timestamp">
        ///     The time when the input occured.
        /// </param>
        /// <param name="systemGesture">
        ///     The type of system gesture.
        /// </param>
        public StylusSystemGestureEventArgs(
            StylusDevice stylusDevice, int timestamp,
            SystemGesture systemGesture) :
            base(stylusDevice, timestamp)
        {
            if (!RawStylusSystemGestureInputReport.IsValidSystemGesture(systemGesture, false, false))
            {
                throw new InvalidEnumArgumentException(SR.Get(SRID.Enum_Invalid, "systemGesture"));
            }

            _id = systemGesture;
        }
        /////////////////////////////////////////////////////////////////////
        /// <summary>
        ///     Initializes a new instance of the StylusSystemGestureEventArgs class.
        /// </summary>
        /// <param name="stylusDevice">
        ///     The logical Stylus device associated with this event.
        /// </param>
        /// <param name="timestamp">
        ///     The time when the input occured.
        /// </param>
        /// <param name="systemGesture">
        ///     The type of system gesture.
        /// </param>
        /// <param name="gestureX">
        ///     The X location reported with this system gesture.  In tablet
        ///     device coordinates.
        /// </param>
        /// <param name="gestureY">
        ///     The Y location reported with this system gesture.  In tablet
        ///     device coordinates.
        /// </param>
        /// <param name="buttonState">
        ///     The button state at the time of the system gesture.
        ///     Note: A flick gesture will pass the flick data in the parameter.
        /// </param>
        internal StylusSystemGestureEventArgs(
            StylusDevice stylusDevice,
            int timestamp,
            SystemGesture systemGesture,
            int gestureX,
            int gestureY,
            int buttonState) :
            base(stylusDevice, timestamp)
        {
            if (!RawStylusSystemGestureInputReport.IsValidSystemGesture(systemGesture, true, false))
            {
                throw new InvalidEnumArgumentException(SR.Get(SRID.Enum_Invalid, "systemGesture"));
            }

            _id          = systemGesture;
            _buttonState = buttonState;
            _gestureX    = gestureX;
            _gestureY    = gestureY;
        }
        private void OnSystemGesture(RawStylusSystemGestureInputReport stylusInputReport)
        { 
            switch (_currentState) 
            {
                case State.TwoFingersDown: 
                    switch (stylusInputReport.SystemGesture)
                    {
                        case SystemGesture.Drag:
                        case SystemGesture.RightDrag: 
                        case SystemGesture.Flick:
                            // One of the two fingers made a Wisptis detected gesture 
                            // that prevents TwoFingerTap or Rollover. 
                            _currentState = State.TwoFingersInWisptisGesture;
                            break; 
                    }
                    break;

                case State.OneFingerInStaticGesture: 
                case State.OneFingerDown:
                    switch (stylusInputReport.SystemGesture) 
                    { 
                        case SystemGesture.Drag:
                        case SystemGesture.RightDrag: 
                        case SystemGesture.Flick:
                            // A finger made a Wisptis detected gesture
                            // that prevents TwoFingerTap or Rollover.
                            _currentState = State.OneFingerInWisptisGesture; 
                            break;
                    } 
                    break; 
            }
        } 
        private void UpdateStateForSystemGesture(SystemGesture gesture, RawStylusSystemGestureInputReport report)
        {
            switch (gesture)
            {
                case SystemGesture.Tap:
                case SystemGesture.Drag:
                    // request the next mouse move to become LeftButtonDown
                    _fLeftButtonDownTrigger = true;
                    _fGestureWasFired = true;
                    break;
                case SystemGesture.RightTap:
                case SystemGesture.RightDrag:
                    // request the next mouse move to become RightButtonDown
                    _fLeftButtonDownTrigger = false;
                    _fGestureWasFired = true;
                    break;
                case SystemGesture.HoldEnter:
                    // press & hold animation started..
                    _seenHoldEnterGesture = true;
                    break;
                case SystemGesture.Flick:
                    // We don't do any mouse promotion for a flick!
                    _fGestureWasFired = true;

                    // Update the stylus location info just for flick gestures.  This is because
                    // we want to fire the flick event not from the last stylus location
                    // (end of flick gesture) but from the beginning of the flick gesture
                    // (stylus down point) since this is the element that we query whether they
                    // allow flicks and since scrolling is targetted we need to scroll the
                    // element you really flicked on.

                    // Only route the flick if we have data we can send.
                    if (report != null && report.InputSource != null && _eventStylusPoints != null && _eventStylusPoints.Count > 0)
                    {
                        StylusPoint stylusPoint = _eventStylusPoints[_eventStylusPoints.Count - 1];

                        stylusPoint.X = report.GestureX;
                        stylusPoint.Y = report.GestureY;

                        // Update the current point with this data.
                        _eventStylusPoints = new StylusPointCollection(stylusPoint.Description,
                                                                       stylusPoint.GetPacketData(),
                                                                       GetTabletToElementTransform(null),
                                                                       Matrix.Identity);

                        PresentationSource inputSource = DetermineValidSource(report.InputSource, _eventStylusPoints, report.PenContext.Contexts);

                        if (inputSource != null)
                        {
                            // See if we need to remap the stylus data X and Y values to different presentation source.
                            if (inputSource != report.InputSource)
                            {
                                Point newWindowLocation = PointUtil.ClientToScreen(new Point(0, 0), inputSource);
                                newWindowLocation = _stylusLogic.MeasureUnitsFromDeviceUnits(newWindowLocation);
                                Point oldWindowLocation = _stylusLogic.MeasureUnitsFromDeviceUnits(report.PenContext.Contexts.DestroyedLocation);

                                // Create translate matrix transform to shift coords to map points to new window location.
                                MatrixTransform additionalTransform = new MatrixTransform(new Matrix(1, 0, 0, 1,
                                                                            oldWindowLocation.X - newWindowLocation.X,
                                                                            oldWindowLocation.Y - newWindowLocation.Y));
                                _eventStylusPoints = _eventStylusPoints.Reformat(report.StylusPointDescription, additionalTransform);
                            }

                            _rawPosition = _eventStylusPoints[_eventStylusPoints.Count - 1];
                            _inputSource = new SecurityCriticalDataClass<PresentationSource>(inputSource);
                            Point pt = _stylusLogic.DeviceUnitsFromMeasureUnits((Point)_rawPosition);
                            _lastScreenLocation = PointUtil.ClientToScreen(pt, inputSource);
                        }
                    }

                    break;
            }
        }
 internal void UpdateStateForSystemGesture(RawStylusSystemGestureInputReport report)
 {
     UpdateStateForSystemGesture(report.SystemGesture, report);
 }
Example #9
0
        private void GenerateGesture(RawStylusInputReport rawStylusInputReport, SystemGesture gesture) 
        {
            StylusDevice stylusDevice = rawStylusInputReport.StylusDevice; 
            System.Diagnostics.Debug.Assert(stylusDevice != null); 

            RawStylusSystemGestureInputReport inputReport = new RawStylusSystemGestureInputReport( 
                                                        InputMode.Foreground,
                                                        rawStylusInputReport.Timestamp,
                                                        rawStylusInputReport.InputSource,
                                                        rawStylusInputReport.PenContext, 
                                                        rawStylusInputReport.TabletDeviceId,
                                                        rawStylusInputReport.StylusDeviceId, 
                                                        gesture, 
                                                        0, // Gesture X location (only used for flicks)
                                                        0, // Gesture Y location (only used for flicks) 
                                                        0); // ButtonState (only used for flicks)
            inputReport.StylusDevice = stylusDevice;
            InputReportEventArgs input = new InputReportEventArgs(stylusDevice, inputReport);
            input.RoutedEvent=InputManager.PreviewInputReportEvent; 
            // Process this directly instead of doing a push. We want this event to get
            // to the user before the StylusUp and MouseUp event. 
            InputManagerProcessInputEventArgs(input); 
        }
Example #10
0
        internal void ProcessSystemEvent(PenContext penContext,
                                                  int tabletDeviceId, 
                                                  int stylusDeviceId, 
                                                  int timestamp,
                                                  SystemGesture systemGesture, 
                                                  int gestureX,
                                                  int gestureY,
                                                  int buttonState,
                                                  PresentationSource inputSource) 
        {
            // We only want to process the system events we expose in the public enum 
            // for SystemSystemGesture.  There are a bunch of other system gestures that 
            // can come through.
            if (systemGesture == SystemGesture.Tap || 
                systemGesture == SystemGesture.RightTap ||
                systemGesture == SystemGesture.Drag ||
                systemGesture == SystemGesture.RightDrag ||
                systemGesture == SystemGesture.HoldEnter || 
                systemGesture == SystemGesture.HoldLeave ||
                systemGesture == SystemGesture.HoverEnter || 
                systemGesture == SystemGesture.HoverLeave || 
                systemGesture == SystemGesture.Flick ||
                systemGesture == RawStylusSystemGestureInputReport.InternalSystemGestureDoubleTap || 
                systemGesture == SystemGesture.None)
            {
                Debug.Assert(systemGesture != SystemGesture.None);  // We should ever see this as input.
                RawStylusSystemGestureInputReport inputReport = 
                            new RawStylusSystemGestureInputReport(
                                   InputMode.Foreground, 
                                   timestamp, 
                                   inputSource,
                                   penContext, 
                                   tabletDeviceId,
                                   stylusDeviceId,
                                   systemGesture,
                                   gestureX, // location of system gesture in tablet device coordinates 
                                   gestureY,
                                   buttonState); // flicks passes the flickinfo in this param 
 
                // actions: RawStylusActions.StylusSystemEvent
                ProcessInputReport(inputReport); 
            }
        }