Esempio n. 1
0
        private void Filter(RawStylusInput rawStylusInput)
        {
            // Get the StylusPoints that have come in.
            StylusPointCollection stylusPoints = rawStylusInput.GetStylusPoints();

            // Modify the (X,Y) data to move the points
            // inside the acceptable input area, if necessary.
            for (int i = 0; i < stylusPoints.Count; i++)
            {
                StylusPoint sp = stylusPoints[i];
                if (sp.X < 50)
                {
                    sp.X = 50;
                }
                if (sp.X > 250)
                {
                    sp.X = 250;
                }
                if (sp.Y < 50)
                {
                    sp.Y = 50;
                }
                if (sp.Y > 250)
                {
                    sp.Y = 250;
                }
                stylusPoints[i] = sp;
            }

            // Copy the modified StylusPoints back to the RawStylusInput.
            rawStylusInput.SetStylusPoints(stylusPoints);
        }
Esempio n. 2
0
        private void Filter(RawStylusInput rawStylusInput)
        {
            StylusPointCollection stylusPoints = rawStylusInput.GetStylusPoints();

            for (int i = 0; i < stylusPoints.Count; i++)
            {
                StylusPoint sp = stylusPoints[i];
                if (sp.X < 100)
                {
                    sp.X = 100;
                }
                if (sp.X > 400)
                {
                    sp.X = 400;
                }
                if (sp.Y < 100)
                {
                    sp.Y = 100;
                }
                if (sp.Y > 400)
                {
                    sp.Y = 400;
                }
                stylusPoints[i] = sp;
            }
            rawStylusInput.SetStylusPoints(stylusPoints);
        }
Esempio n. 3
0
        //private void StudentInkCanvas_SpeedCheckedEvent(object sender, StudentInkCanvas.SpeedCheckedEventArgs e)
        //{
        //    IsSpeedChecked = e.state;
        //}

        #endregion

        #region overrides

        protected override void OnStylusDown(RawStylusInput rawStylusInput)
        {
            base.OnStylusDown(rawStylusInput);
            Stroke tempStroke = new Stroke(rawStylusInput.GetStylusPoints());

            //if the styluspoints is not empty
            if (tempStroke.StylusPoints.Count >= 0)
            {
                //get the stroke thats the animation is running on
                ExpertStroke = ExpertStrokeCollection[StudentStrokeCount];
                //set the first point of the stroke as the expert reference point
                ExpertStylusPoint = ExpertStroke.StylusPoints.First();

                if (tempStroke.HitTest(ExpertStylusPoint.ToPoint(), HitThreshold))
                {
                    foreach (StylusPoint sp in tempStroke.StylusPoints)
                    {
                        hitChangedPoints.Add(sp.ToPoint());
                    }
                    StrokeColor = Color.FromArgb(255, 0, 255, 0);
                }
                else
                {
                    StrokeColor = Color.FromArgb(255, 255, 0, 0);
                }
            }
        }
Esempio n. 4
0
        protected override void OnStylusMove(RawStylusInput rawStylusInput)
        {
            var n = rawStylusInput;

            EraserInkView.Count++;
            Debug.WriteLine($"TTTTTTTTTTTT {EraserInkView.Count:D5} " + Environment.TickCount);
            MainWindow.TouchTickCount = Environment.TickCount;



            var TranslateTransform = new TranslateTransform();
            var RotateTransform    = new RotateTransform();
            var ScaleTransform     = new ScaleTransform()
            {
            };



            var stylusPointCollection = rawStylusInput.GetStylusPoints();

            if (stylusPointCollection.Count > 0)
            {
                foreach (var stylusPoint in stylusPointCollection)
                {
                    _mainWindow.Dispatcher.InvokeAsync(() =>
                    {
                        var f1    = n;
                        var point = stylusPoint;

                        _mainWindow.EraserView.X = point.X - _mainWindow.EraserView.Width / 2;
                        _mainWindow.EraserView.Y = point.Y - _mainWindow.EraserView.Height / 2;
                    }, DispatcherPriority.Send);
                }
            }
        }
    protected override void OnStylusDown(RawStylusInput rawStylusInput)
    {
        // Run the base class before modifying the data
        base.OnStylusDown(rawStylusInput);
        Debug.Log("Stylus Down");

        /*
         * if (currentStylus == -1)
         * {
         *  StylusPointCollection pointsFromEvent = rawStylusInput.GetStylusPoints();
         *
         *  // Create an emtpy StylusPointCollection to contain the filtered
         *  // points.
         *  collectedPoints = new StylusPointCollection(pointsFromEvent.Description);
         *
         *  // Restrict the stylus input and add the filtered
         *  // points to collectedPoints.
         *  StylusPointCollection points = FilterPackets(pointsFromEvent);
         *  rawStylusInput.SetStylusPoints(points);
         *  collectedPoints.Add(points);
         *
         *  currentStylus = rawStylusInput.StylusDeviceId;
         * }
         */
    }
Esempio n. 6
0
        //</Snippet9>

        //<Snippet10>
        protected override void OnStylusUp(RawStylusInput rawStylusInput)
        {
            // Run the base class before modifying the data
            base.OnStylusUp(rawStylusInput);

            // Get the StylusPoints that have come in
            StylusPointCollection stylusPoints = rawStylusInput.GetStylusPoints();

            // Modify the (X,Y) data to move the points
            // inside the acceptable input area, if necessary
            for (int i = 0; i < stylusPoints.Count; i++)
            {
                StylusPoint sp = stylusPoints[i];
                if (sp.X < 50)
                {
                    sp.X = 50;
                }
                if (sp.X > 250)
                {
                    sp.X = 250;
                }
                if (sp.Y < 50)
                {
                    sp.Y = 50;
                }
                if (sp.Y > 250)
                {
                    sp.Y = 250;
                }
                stylusPoints[i] = sp;
            }

            // Copy the modified StylusPoints back to the RawStylusInput
            rawStylusInput.SetStylusPoints(stylusPoints);
        }
Esempio n. 7
0
        protected override void OnStylusMove(RawStylusInput rawStylusInput)
        {
            StylusPointCollection stylusPoints = rawStylusInput.GetStylusPoints();

            this.Reset(Stylus.CurrentStylusDevice, stylusPoints);
            base.OnStylusMove(rawStylusInput);
        }
Esempio n. 8
0
        internal StylusPlugInCollection InvokeStylusPluginCollectionForMouse(RawStylusInputReport inputReport, IInputElement directlyOver, StylusPlugInCollection currentPlugInCollection)
        {
            StylusPlugInCollection newPlugInCollection = null;

            // lock to make sure only one event is processed at a time and no changes to state can
            // be made until we finish routing this event.
            lock (__rtiLock)
            {
                //Debug.Assert(inputReport.Actions == RawStylusActions.Down ||
                //             inputReport.Actions == RawStylusActions.Up ||
                //             inputReport.Actions == RawStylusActions.Move);

                // Find new target plugin collection
                if (directlyOver != null)
                {
                    UIElement uiElement = InputElement.GetContainingUIElement(directlyOver as DependencyObject) as UIElement;
                    if (uiElement != null)
                    {
                        newPlugInCollection = FindPlugInCollection(uiElement);
                    }
                }

                // Fire Leave event to old pluginCollection if we need to.
                if (currentPlugInCollection != null && currentPlugInCollection != newPlugInCollection)
                {
                    // NOTE: input report points for mouse are in avalon measured units and not device!
                    RawStylusInput tempRawStylusInput = new RawStylusInput(inputReport, currentPlugInCollection.ViewToElement, currentPlugInCollection);

                    currentPlugInCollection.FireEnterLeave(false, tempRawStylusInput, true);

                    // Indicate we've used a stylus plugin
                    _stylusLogic.Statistics.FeaturesUsed |= Tracing.StylusTraceLogger.FeatureFlags.StylusPluginsUsed;
                }
                if (newPlugInCollection != null)
                {
                    // NOTE: input report points for mouse are in avalon measured units and not device!
                    RawStylusInput rawStylusInput = new RawStylusInput(inputReport, newPlugInCollection.ViewToElement, newPlugInCollection);
                    inputReport.RawStylusInput = rawStylusInput;

                    if (newPlugInCollection != currentPlugInCollection)
                    {
                        newPlugInCollection.FireEnterLeave(true, rawStylusInput, true);
                    }

                    // We are on the pen thread, just call directly.
                    newPlugInCollection.FireRawStylusInput(rawStylusInput);

                    // Indicate we've used a stylus plugin
                    _stylusLogic.Statistics.FeaturesUsed |= Tracing.StylusTraceLogger.FeatureFlags.StylusPluginsUsed;

                    // Fire custom data events (always confirmed for mouse)
                    foreach (RawStylusInputCustomData customData in rawStylusInput.CustomDataList)
                    {
                        customData.Owner.FireCustomData(customData.Data, inputReport.Actions, true);
                    }
                }
            }
            return(newPlugInCollection);
        }
Esempio n. 9
0
        protected override void OnStylusDown(RawStylusInput rawStylusInput)
        {
            var stylusPoints = rawStylusInput.GetStylusPoints();

            _downPoint = (Point)stylusPoints[0];
            _prevPoint = new Point(double.NegativeInfinity, double.NegativeInfinity);
            base.OnStylusDown(rawStylusInput);
        }
Esempio n. 10
0
        protected override void OnStylusUp(RawStylusInput rawStylusInput)
        {
            // Call the base class before modifying the data.
            base.OnStylusUp(rawStylusInput);

            // Restrict the stylus input
            Filter(rawStylusInput);
        }
Esempio n. 11
0
 protected override void OnStylusDown(RawStylusInput rawStylusInput)
 {
     myInkCanvas.isFromFileInk = false;
     inkTool = CreateFromInkData(myInkCanvas.myData);
     inkDA   = myInkCanvas.inkDA.Clone();
     this.DrawingAttributes = inkDA;
     previousPoint          = new Point(double.NegativeInfinity, double.NegativeInfinity);
     base.OnStylusDown(rawStylusInput);
 }
Esempio n. 12
0
        // </Snippet15>

        //<Snippet14>
        // If the element loses focus, stop collecting the points and don't
        // perform gesture recognition.
        protected override void OnStylusLeave(RawStylusInput rawStylusInput, bool confirmed)
        {
            if (confirmed)
            {
                // Clear the StylusPointCollection
                points        = null;
                currentStylus = 0;
            }
        }
Esempio n. 13
0
 // Collect the points as the user draws the stroke.
 protected override void OnStylusMove(RawStylusInput rawStylusInput)
 {
     // Check whether the stylus that started the stroke is the same, and
     // that the element hasn't lost focus since the stroke began.
     if (points != null && currentStylus == rawStylusInput.StylusDeviceId)
     {
         points.Add(rawStylusInput.GetStylusPoints());
     }
 }
Esempio n. 14
0
        protected override void OnStylusMove(RawStylusInput rawStylusInput)
        {
            var movePoint = rawStylusInput.GetStylusPoints()[0];
            var now       = DateTime.Now;
            var stamp     = (now - currentStroke.DownStylusPointStamp).Ticks;

            currentStroke.StampedStylusPoints.Add(new StampedStylusPoint {
                Stamp = stamp, StylusPoint = movePoint
            });
            base.OnStylusMove(rawStylusInput);
        }
Esempio n. 15
0
        protected override void OnStylusMove(RawStylusInput rawStylusInput)
        {
            int num = rawStylusInput.StylusDeviceId;

            if (!AllowsMouseInput)
            {
                return;
            }
            this.Move(rawStylusInput.StylusDeviceId, rawStylusInput.Timestamp, rawStylusInput.GetStylusPoints());
            base.OnStylusMove(rawStylusInput);
        }
Esempio n. 16
0
 // <Snippet15>
 // Collect the points as the user draws the stroke.
 protected override void OnStylusDown(RawStylusInput rawStylusInput)
 {
     // If points is not null, there is already a stroke taking place
     // on the digitizer, so don't create a new StylusPointsCollection.
     if (points == null)
     {
         points = new StylusPointCollection(rawStylusInput.GetStylusPoints().Description);
         points.Add(rawStylusInput.GetStylusPoints());
         currentStylus = rawStylusInput.StylusDeviceId;
     }
 }
Esempio n. 17
0
        protected override void OnStylusUp(RawStylusInput rawStylusInput)
        {
            base.OnStylusUp(rawStylusInput);
            //raise the event and pass the collection
            HitChangePointsEventArgs args = new HitChangePointsEventArgs();

            args.hitChangedPoints = hitChangedPoints;
            OnHitChangePoints(args);
            //reset the collection
            hitChangedPoints = new List <Point>();
        }
        protected override void OnStylusMove(RawStylusInput rawStylusInput)
        {
            StylusPointCollection stylusPoints = rawStylusInput.GetStylusPoints();

            //// 让收集到的点只剩下起点和终点
            while (stylusPoints.Count > 2)
            {
                stylusPoints.RemoveAt(stylusPoints.Count - 2);
            }

            this.Reset(Stylus.CurrentStylusDevice, stylusPoints);
            base.OnStylusMove(rawStylusInput);
        }
Esempio n. 19
0
        /// <summary>
        /// </summary>
        internal StylusPlugInCollection InvokeStylusPluginCollectionForMouse(RawStylusInputReport inputReport, IInputElement directlyOver, StylusPlugInCollection currentPlugInCollection)
        {
            StylusPlugInCollection newPlugInCollection = null;

            // Find new target plugin collection
            if (directlyOver != null)
            {
                UIElement uiElement = InputElement.GetContainingUIElement(directlyOver as DependencyObject) as UIElement;
                if (uiElement != null)
                {
                    newPlugInCollection = FindPlugInCollection(uiElement);
                }
            }

            // Fire Leave event to old pluginCollection if we need to.
            if (currentPlugInCollection != null && currentPlugInCollection != newPlugInCollection)
            {
                // NOTE: input report points for mouse are in avalon measured units and not device!
                RawStylusInput tempRawStylusInput = new RawStylusInput(inputReport, currentPlugInCollection.ViewToElement, currentPlugInCollection);

                currentPlugInCollection.FireEnterLeave(false, tempRawStylusInput, true);

                // Indicate we've used a stylus plugin
                StylusLogic.CurrentStylusLogic.Statistics.FeaturesUsed |= Tracing.StylusTraceLogger.FeatureFlags.StylusPluginsUsed;
            }
            if (newPlugInCollection != null)
            {
                // NOTE: input report points for mouse are in avalon measured units and not device!
                RawStylusInput rawStylusInput = new RawStylusInput(inputReport, newPlugInCollection.ViewToElement, newPlugInCollection);
                inputReport.RawStylusInput = rawStylusInput;

                if (newPlugInCollection != currentPlugInCollection)
                {
                    newPlugInCollection.FireEnterLeave(true, rawStylusInput, true);
                }

                // (Comment not applicable until RTI back in) We are on the RTI thread, just call directly.
                newPlugInCollection.FireRawStylusInput(rawStylusInput);

                // Indicate we've used a stylus plugin
                StylusLogic.CurrentStylusLogic.Statistics.FeaturesUsed |= Tracing.StylusTraceLogger.FeatureFlags.StylusPluginsUsed;

                // Fire custom data events (always confirmed for mouse)
                foreach (RawStylusInputCustomData customData in rawStylusInput.CustomDataList)
                {
                    customData.Owner.FireCustomData(customData.Data, inputReport.Actions, true);
                }
            }

            return(newPlugInCollection);
        }
Esempio n. 20
0
 protected override void OnStylusDown(RawStylusInput rawStylusInput)
 {
     rs = rawStylusInput;
     try {
         // TJC: only take in stylus ink, not multitouch
         // this prevents drawing the ink as we move our touches (e.g. scale/pan)
         bool isStylus = rs.StylusDeviceId == STYLUS_ID;
         if (isStylus)
         {
             base.OnStylusDown(rawStylusInput);
         }
     }
     catch (Exception) { }
 }
Esempio n. 21
0
        // Collect the points as the user draws the stroke.
        protected override void OnStylusUp(RawStylusInput rawStylusInput)
        {
            // Check whether the stylus that started the stroke is the same, and
            // that the element hasn't lost focus since the stroke began.
            if (points != null && currentStylus == rawStylusInput.StylusDeviceId)
            {
                points.Add(rawStylusInput.GetStylusPoints());

                // Subscribe to the OnStylusUpProcessed method.
                rawStylusInput.NotifyWhenProcessed(points);
            }

            points        = null;
            currentStylus = 0;
        }
Esempio n. 22
0
        protected override void OnStylusMove(RawStylusInput rawStylusInput)
        {
            base.OnStylusMove(rawStylusInput);
            //collect the stylus point
            StylusPointCollection tempStylusPoints = rawStylusInput.GetStylusPoints();

            //if there are no points in the collection
            if (tempStylusPoints.Count <= 0)
            {
                return;
            }
            ExpertStylusPoint = ReturnExpertStylusPoint(tempStylusPoints, ExpertStylusPoint, ExpertStroke);
            Debug.WriteLine("ExpertStylusPoint Index: " + ExpertStroke.StylusPoints.IndexOf(ExpertStylusPoint));
            rawStylusInput.NotifyWhenProcessed(tempStylusPoints);
        }
Esempio n. 23
0
        private void Transform(RawStylusInput rawStylusInput)
        {
            StylusPointCollection stylusPoints = rawStylusInput.GetStylusPoints();

            for (int i = 0; i < stylusPoints.Count; i++)
            {
                StylusPoint sp = stylusPoints[i];
                Point       pt = (Point)sp;
                pt             *= _matrix;
                sp.X            = pt.X;
                sp.Y            = pt.Y;
                stylusPoints[i] = sp;
            }
            rawStylusInput.SetStylusPoints(stylusPoints);
        }
Esempio n. 24
0
        protected override void OnStylusMove(RawStylusInput rawStylusInput)
        {
            // Run the base class before modifying the data
            base.OnStylusMove(rawStylusInput);

            if (currentStylus == rawStylusInput.StylusDeviceId)
            {
                StylusPointCollection pointsFromEvent = rawStylusInput.GetStylusPoints();

                // Restrict the stylus input and add the filtered
                // points to collectedPoints.
                StylusPointCollection points = FilterPackets(pointsFromEvent);
                rawStylusInput.SetStylusPoints(points);
                collectedPoints.Add(points);
            }
        }
Esempio n. 25
0
        protected override void OnStylusUp(RawStylusInput rawStylusInput)
        {
            // Run the base class before modifying the data
            base.OnStylusUp(rawStylusInput);

            if (currentStylus == rawStylusInput.StylusDeviceId)
            {
                StylusPointCollection pointsFromEvent = rawStylusInput.GetStylusPoints();

                // Restrict the stylus input and add the filtered
                // points to collectedPoints.
                StylusPointCollection points = FilterPackets(pointsFromEvent);
                rawStylusInput.SetStylusPoints(points);
                collectedPoints.Add(points);

                // Subscribe to the OnStylusUpProcessed method.
                rawStylusInput.NotifyWhenProcessed(collectedPoints);

                currentStylus = -1;
            }
        }
Esempio n. 26
0
 protected override void OnStylusUp(RawStylusInput RawStylusInput)
 {
     _firstPoint = new Point(double.NegativeInfinity, double.NegativeInfinity);
     base.OnStylusUp(RawStylusInput);
 }
Esempio n. 27
0
 protected override void OnStylusDown(RawStylusInput RawStylusInput)
 {
     _firstPoint = RawStylusInput.GetStylusPoints().First().ToPoint();
     base.OnStylusDown(RawStylusInput);
 }
Esempio n. 28
0
 protected override void OnStylusDown(RawStylusInput rawStylusInput)
 {
     // Allocate memory to store the previous point to draw from.
     prevPoint = new Point(double.NegativeInfinity, double.NegativeInfinity);
     base.OnStylusDown(rawStylusInput);
 }
Esempio n. 29
0
        internal void InvokeStylusPluginCollection(RawStylusInputReport inputReport)
        {
            // Find PenContexts object for this inputReport.
            StylusPlugInCollection pic = null;

            // lock to make sure only one event is processed at a time and no changes to state can
            // be made until we finish routing this event.
            lock (__rtiLock)
            {
                switch (inputReport.Actions)
                {
                case RawStylusActions.Down:
                case RawStylusActions.Move:
                case RawStylusActions.Up:
                    // Figure out current target plugincollection.
                    pic = TargetPlugInCollection(inputReport);
                    break;

                default:
                    return;     // Nothing to do unless one of the above events
                }

                WispStylusDevice stylusDevice = inputReport.StylusDevice.As <WispStylusDevice>();

                StylusPlugInCollection currentPic = stylusDevice.CurrentNonVerifiedTarget;

                // Fire Leave event if we need to.
                if (currentPic != null && currentPic != pic)
                {
                    // Create new RawStylusInput to send
                    GeneralTransformGroup transformTabletToView = new GeneralTransformGroup();
                    transformTabletToView.Children.Add(new MatrixTransform(_stylusLogic.GetTabletToViewTransform(stylusDevice.TabletDevice))); // this gives matrix in measured units (not device)
                    transformTabletToView.Children.Add(currentPic.ViewToElement);                                                              // Make it relative to the element.
                    transformTabletToView.Freeze();                                                                                            // Must be frozen for multi-threaded access.

                    RawStylusInput tempRawStylusInput = new RawStylusInput(inputReport, transformTabletToView, currentPic);

                    currentPic.FireEnterLeave(false, tempRawStylusInput, false);

                    // Indicate we've used a stylus plugin
                    _stylusLogic.Statistics.FeaturesUsed |= Tracing.StylusTraceLogger.FeatureFlags.StylusPluginsUsed;
                    stylusDevice.CurrentNonVerifiedTarget = null;
                }

                if (pic != null)
                {
                    // NOTE: PenContext info will not change (it gets rebuilt instead so keeping ref is fine)
                    //    The transformTabletToView matrix and plugincollection rects though can change based
                    //    off of layout events which is why we need to lock this.
                    GeneralTransformGroup transformTabletToView = new GeneralTransformGroup();
                    transformTabletToView.Children.Add(new MatrixTransform(_stylusLogic.GetTabletToViewTransform(stylusDevice.TabletDevice))); // this gives matrix in measured units (not device)
                    transformTabletToView.Children.Add(pic.ViewToElement);                                                                     // Make it relative to the element.
                    transformTabletToView.Freeze();                                                                                            // Must be frozen for multi-threaded access.

                    RawStylusInput rawStylusInput = new RawStylusInput(inputReport, transformTabletToView, pic);
                    inputReport.RawStylusInput = rawStylusInput;

                    if (pic != currentPic)
                    {
                        stylusDevice.CurrentNonVerifiedTarget = pic;
                        pic.FireEnterLeave(true, rawStylusInput, false);
                    }

                    // We are on the pen thread, just call directly.
                    pic.FireRawStylusInput(rawStylusInput);

                    // Indicate we've used a stylus plugin
                    _stylusLogic.Statistics.FeaturesUsed |= Tracing.StylusTraceLogger.FeatureFlags.StylusPluginsUsed;
                }
            } // lock(__rtiLock)
        }
Esempio n. 30
0
 protected override void OnStylusUp(RawStylusInput rawStylusInput)
 {
     first = false;
     base.OnStylusUp(rawStylusInput);
 }