Exemplo n.º 1
0
        internal override void Synchronize()
        {
            // Simulate a stylus move (if we are current stylus, inrange, visuals still valid to update
            // and has moved).
            if (InRange && _inputSource != null && _inputSource.Value != null &&
                _inputSource.Value.CompositionTarget != null && !_inputSource.Value.CompositionTarget.IsDisposed)
            {
                Point rawScreenPoint = new Point(_pointerData.Info.ptPixelLocationRaw.X, _pointerData.Info.ptPixelLocationRaw.Y);
                Point ptDevice       = PointUtil.ScreenToClient(rawScreenPoint, _inputSource.Value);

                // GlobalHitTest always returns an IInputElement, so we are sure to have one.
                IInputElement stylusOver     = Input.StylusDevice.GlobalHitTest(_inputSource.Value, ptDevice);
                bool          fOffsetChanged = false;

                if (_stylusOver == stylusOver)
                {
                    Point ptOffset = GetPosition(stylusOver);
                    fOffsetChanged = MS.Internal.DoubleUtil.AreClose(ptOffset.X, _rawElementRelativePosition.X) == false || MS.Internal.DoubleUtil.AreClose(ptOffset.Y, _rawElementRelativePosition.Y) == false;
                }

                if (fOffsetChanged || _stylusOver != stylusOver)
                {
                    int timeStamp = Environment.TickCount;

                    if (_currentStylusPoints != null &&
                        _currentStylusPoints.Count > 0 &&
                        StylusPointDescription.AreCompatible(PointerTabletDevice.StylusPointDescription, _currentStylusPoints.Description))
                    {
                        StylusPoint stylusPoint = _currentStylusPoints[_currentStylusPoints.Count - 1];
                        int[]       data        = stylusPoint.GetPacketData();

                        // get back to the correct coordinate system
                        Matrix m = _tabletDevice.TabletToScreen;
                        m.Invert();
                        Point ptTablet = ptDevice * m;

                        data[0] = (int)ptTablet.X;
                        data[1] = (int)ptTablet.Y;

                        RawStylusInputReport report = new RawStylusInputReport(InputMode.Foreground,
                                                                               timeStamp,
                                                                               _inputSource.Value,
                                                                               InAir ? RawStylusActions.InAirMove : RawStylusActions.Move,
                                                                               () => { return(PointerTabletDevice.StylusPointDescription); },
                                                                               TabletDevice.Id,
                                                                               Id,
                                                                               data);


                        report.Synchronized = true;

                        InputReportEventArgs inputReportEventArgs = new InputReportEventArgs(StylusDevice, report);
                        inputReportEventArgs.RoutedEvent = InputManager.PreviewInputReportEvent;

                        InputManager.Current.ProcessInput(inputReportEventArgs);
                    }
                }
            }
        }
Exemplo n.º 2
0
        void CompareDescriptions()
        {
            //<Snippet22>
            StylusPointDescription description1 =
                new StylusPointDescription(new StylusPointPropertyInfo[]
            {
                new StylusPointPropertyInfo(StylusPointProperties.X),
                new StylusPointPropertyInfo(StylusPointProperties.Y),
                new StylusPointPropertyInfo(StylusPointProperties.NormalPressure),
                new StylusPointPropertyInfo(StylusPointProperties.XTiltOrientation),
                new StylusPointPropertyInfo(StylusPointProperties.YTiltOrientation),
                new StylusPointPropertyInfo(StylusPointProperties.BarrelButton)
            });

            StylusPointDescription description2 =
                new StylusPointDescription(new StylusPointPropertyInfo[]
            {
                new StylusPointPropertyInfo(StylusPointProperties.X),
                new StylusPointPropertyInfo(StylusPointProperties.Y),
                new StylusPointPropertyInfo(StylusPointProperties.NormalPressure),
                new StylusPointPropertyInfo(StylusPointProperties.BarrelButton)
            });

            //</Snippet22>

            //<Snippet23>
            if (StylusPointDescription.AreCompatible(description1, description2))
            {
                MessageBox.Show("The two descriptions are compatible.");
            }
            else
            {
                MessageBox.Show("The two descriptions are not compatible.");
            }
            //</Snippet23>

            //<Snippet24>
            if (description2.IsSubsetOf(description1))
            {
                MessageBox.Show("description2 is a subset of description1.");
            }
            else
            {
                MessageBox.Show("description2 is not a subset of description1.");
            }
            //</Snippet24>
        }
Exemplo n.º 3
0
        /// <summary>
        /// Replaces the StylusPoints.
        /// </summary>
        /// <remarks>
        ///     Callers must have Unmanaged code permission to call this API.
        /// </remarks>
        /// <param name="stylusPoints">stylusPoints</param>
        public void SetStylusPoints(StylusPointCollection stylusPoints)
        {
            if (null == stylusPoints)
            {
                throw new ArgumentNullException("stylusPoints");
            }

            if (!StylusPointDescription.AreCompatible(stylusPoints.Description,
                                                      _report.StylusPointDescription))
            {
                throw new ArgumentException(SR.Get(SRID.IncompatibleStylusPointDescriptions), "stylusPoints");
            }
            if (stylusPoints.Count == 0)
            {
                throw new ArgumentException(SR.Get(SRID.Stylus_StylusPointsCantBeEmpty), "stylusPoints");
            }

            _stylusPoints = stylusPoints.Clone();
        }
Exemplo n.º 4
0
        public void SetStylusPoints(StylusPointCollection stylusPoints)
        {
            // To modify the points we require Unmanaged code permission.
            SecurityHelper.DemandUnmanagedCode();

            if (null == stylusPoints)
            {
                throw new ArgumentNullException("stylusPoints");
            }

            if (!StylusPointDescription.AreCompatible(stylusPoints.Description,
                                                      _report.StylusPointDescription))
            {
                throw new ArgumentException(SR.Get(SRID.IncompatibleStylusPointDescriptions), "stylusPoints");
            }
            if (stylusPoints.Count == 0)
            {
                throw new ArgumentException(SR.Get(SRID.Stylus_StylusPointsCantBeEmpty), "stylusPoints");
            }

            _stylusPoints = stylusPoints.Clone();
        }