Exemplo n.º 1
0
        private void MCanvas_StylusMove(object sender, StylusEventArgs e)
        {
            float pressure = e.GetStylusPoints((IInputElement)sender).Select(i => i.PressureFactor).Average();
            var   xy       = e.GetPosition((IInputElement)sender);
            var   x        = xy.X;
            var   y        = xy.Y;
            bool  inair    = e.InAir;
            var   point    = e.GetStylusPoints((IInputElement)sender).First();

            // point descriptors
            bool barrel = default;
            int  pitch  = default;
            int  roll   = default;
            int  yaw    = default;

            if (point.Description.HasProperty(StylusPointProperties.BarrelButton))
            {
                barrel = point.GetPropertyValue(StylusPointProperties.BarrelButton) != 0;
            }

            /* if (point.Description.HasProperty(StylusPointProperties.PitchRotation))
             *  pitch = point.GetPropertyValue(StylusPointProperties.PitchRotation);
             *
             * if (point.Description.HasProperty(StylusPointProperties.RollRotation))
             *  roll = point.GetPropertyValue(StylusPointProperties.RollRotation);
             *
             * if (point.Description.HasProperty(StylusPointProperties.YawRotation))
             *  yaw = point.GetPropertyValue(StylusPointProperties.YawRotation); */

            mDeviceUpdater.ProcessAndEnqueueUpdate(x, y, xmax, ymax, pressure, inair, false, barrel);
            textbox.Text = $"at {x}, {y} with pressure {pressure} {(inair ? "in air" : "touching")} - {(barrel ? "barrel" : "")} - {yaw};{pitch};{roll}";
        }
Exemplo n.º 2
0
        // Collect the StylusPackets as the stylus moves.
        protected override void OnStylusMove(StylusEventArgs e)
        {
            switch (state)
            {
            case sMode.add:
                stylusPoints.Add(e.GetStylusPoints(this));
                break;

            default:
                myIncrementalHitTester.AddPoints(e.GetStylusPoints(this));
                break;
            }

            e.Handled = true;
        }
        public void OnStylusMoved(StylusEventArgs e)
        {
            StylusPointCollection strokePoints = e.GetStylusPoints((UIElement)e.OriginalSource);

            if (strokePoints.Count == 0)
            {
                SendDebugMessage("No StylusPoints");
                return;
            }
            if (ExpertIsRecording == true)
            {
                Task.Run(() => {
                    foreach (StylusPoint sp in strokePoints)
                    {
                        PenPressure = sp.GetPropertyValue(StylusPointProperties.NormalPressure);
                        Tilt_X      = sp.GetPropertyValue(StylusPointProperties.XTiltOrientation);
                        Tilt_Y      = sp.GetPropertyValue(StylusPointProperties.YTiltOrientation);
                        Pos_X       = sp.GetPropertyValue(StylusPointProperties.X);
                        Pos_Y       = sp.GetPropertyValue(StylusPointProperties.Y);
                        //StrokeVelocity = 0d;
                        SendDataAsync();
                    }
                });
            }
        }
Exemplo n.º 4
0
        //</Snippet9>

        //<Snippet10>
        // Unsubscribe from the StrokeHitChanged event when the
        // user lifts the stylus.
        protected override void OnStylusUp(StylusEventArgs e)
        {
            eraseTester.AddPoints(e.GetStylusPoints(this));
            eraseTester.StrokeHit -= new
                                     StrokeHitEventHandler(eraseTester_StrokeHit);
            eraseTester.EndHitTesting();
        }
Exemplo n.º 5
0
        protected override void OnStylusUp(StylusEventArgs e)
        {
            if (stylusPoints == null)
            {
                stylusPoints = new StylusPointCollection();
            }
            StylusPointCollection newStylusPoints = e.GetStylusPoints(this, stylusPoints.Description);

            stylusPoints.Add(newStylusPoints);

            Stroke3D stroke = new Stroke3D(stylusPoints);

            if (inPlugins.Contains(customrenderer))
            {
                stroke.AddPropertyData(guidUsingCustomRenderer, 1);
            }
            if (inPlugins.Contains(dynamicRenderer))
            {
                stroke.AddPropertyData(guidUsingStandardRenderer, 1);
            }
            ip.Strokes.Add(stroke);

            stylusPoints = null;
            Stylus.Capture(null);
        }
Exemplo n.º 6
0
        //</Snippet4>

        //<Snippet9>
        // Collect the StylusPackets as the stylus moves.
        protected override void OnStylusMove(StylusEventArgs e)
        {
            if (eraseTester.IsValid)
            {
                eraseTester.AddPoints(e.GetStylusPoints(this));
            }
        }
        /// <summary>
        /// Handles a <see cref="E:Stylus" /> event.
        /// </summary>
        /// <param name="e">The <see cref="StylusEventArgs"/> instance containing the event data.</param>
        /// <param name="touchEventType">The <see cref="TouchEventType"/> event type</param>
        private void OnStylus(StylusEventArgs e, TouchEventType touchEventType)
        {
            var browser = GetBrowser();

            var stylusPoints = e.GetStylusPoints(this);

            if (!e.Handled && browser != null && e.StylusDevice != null && e.StylusDevice.TabletDevice.Type == TabletDeviceType.Stylus && stylusPoints.Count > 0)
            {
                var modifiers   = WpfExtensions.GetModifierKeys();
                var pressure    = stylusPoints[0].PressureFactor;
                var pointerType = e.StylusDevice.Inverted ? PointerType.Eraser : PointerType.Pen;

                var touchEvent = new TouchEvent()
                {
                    Id          = e.StylusDevice.Id,
                    X           = (float)stylusPoints[0].X,
                    Y           = (float)stylusPoints[0].Y,
                    PointerType = pointerType,
                    Pressure    = pressure,
                    Type        = touchEventType,
                    Modifiers   = modifiers,
                };

                browser.GetHost().SendTouchEvent(touchEvent);

                e.Handled = true;
            }
        }
Exemplo n.º 8
0
        //</Snippet8>

        //<Snippet10>
        protected override void OnStylusUp(StylusEventArgs e)
        {
            if (stylusPoints == null)
            {
                return;
            }

            // Add the StylusPoints that have come in since the
            // last call to OnStylusMove.
            StylusPointCollection newStylusPoints =
                e.GetStylusPoints(this, stylusPoints.Description);

            stylusPoints.Add(newStylusPoints);

            // Create a new stroke from all the StylusPoints since OnStylusDown.
            Stroke stroke = new Stroke(stylusPoints);

            // Add the new stroke to the Strokes collection of the InkPresenter.
            ip.Strokes.Add(stroke);

            // Clear the StylusPointsCollection.
            stylusPoints = null;

            // Release stylus capture.
            Stylus.Capture(null);
        }
Exemplo n.º 9
0
        protected override void OnStylusUp(StylusEventArgs e)
        {
            // Allocate memory for the StylusPointsCollection, if necessary
            if (stylusPoints == null)
            {
                stylusPoints = new StylusPointCollection();
            }

            // Add the StylusPoints that have come in since the last call to OnStylusMove
            StylusPointCollection newStylusPoints = e.GetStylusPoints(this, stylusPoints.Description);

            stylusPoints.Add(newStylusPoints);

            // Create a new custom stroke from all the StylusPoints since OnStylusDown
            //Stroke3D stroke = new Stroke3D(stylusPoints);

            Stroke stroke = new Stroke(stylusPoints, currentAttributes.Clone());

            // Add the new stroke to the Strokes collection of the InkPresenter
            inkPresenter1.Strokes.Add(stroke);

            // Clear out the StylusPointsCollection
            stylusPoints = null;

            // Release stylus capture
            Stylus.Capture(null);
        }
Exemplo n.º 10
0
        private void StylusMoveEventHandler(object sender, StylusEventArgs e)
        {
            StylusPointCollection points = e.GetStylusPoints(inkCanvas1);

            WriteStylusPointValues(points);
            WriteDescriptionInfo(points);
        }
        /// <summary>
        /// Handles a <see cref="E:Stylus" /> event.
        /// </summary>
        /// <param name="e">The <see cref="StylusEventArgs"/> instance containing the event data.</param>
        /// <param name="touchEventType">The <see cref="TouchEventType"/> event type</param>
        private void OnStylus(StylusEventArgs e, TouchEventType touchEventType)
        {
            var browser = GetBrowser();

            if (!e.Handled && browser != null)
            {
                var modifiers   = WpfExtensions.GetModifierKeys();
                var pointerType = e.StylusDevice.Inverted ? PointerType.Eraser : PointerType.Pen;
                //Send all points to host
                foreach (var stylusPoint in e.GetStylusPoints(this))
                {
                    var touchEvent = new TouchEvent()
                    {
                        Id          = e.StylusDevice.Id,
                        X           = (float)stylusPoint.X,
                        Y           = (float)stylusPoint.Y,
                        PointerType = pointerType,
                        Pressure    = stylusPoint.PressureFactor,
                        Type        = touchEventType,
                        Modifiers   = modifiers,
                    };

                    browser.GetHost().SendTouchEvent(touchEvent);
                }
                e.Handled = true;
            }
        }
        private void image1_StylusMove(object sender, StylusEventArgs e)
        {
            Point pt = e.GetPosition(image1);
            StylusPointCollection sp = e.GetStylusPoints(image1);

            DrawContinue(pt, sp[0].PressureFactor);
            e.Handled = true;
        }
Exemplo n.º 13
0
        protected override void OnStylusMove(StylusEventArgs e)
        {
            // Allocate memory for the StylusPointsCollection, if necessary
            stylusPoints ??= new StylusPointCollection();

            // Add the StylusPoints that have come in since the last call to OnStylusMove
            StylusPointCollection newStylusPoints = e.GetStylusPoints(this, stylusPoints.Description);

            stylusPoints.Add(newStylusPoints);
        }
Exemplo n.º 14
0
        protected override void OnStylusMove(StylusEventArgs e)
        {
            if (stylusPoints == null)
            {
                stylusPoints = new StylusPointCollection();
            }
            StylusPointCollection newStylusPoints = e.GetStylusPoints(this, stylusPoints.Description);

            stylusPoints.Add(newStylusPoints);
        }
Exemplo n.º 15
0
        private void StylusDebugWindow_StylusMove(object sender, StylusEventArgs e)
        {
            var str = "";

            str += $"Is in air : {e.InAir}";
            var point = e.GetStylusPoints(this).FirstOrDefault();

            str          += "Oh PRESSURE !!!! : " + point.PressureFactor;
            MainInfo.Text = str;
        }
Exemplo n.º 16
0
        private void OnStylusMove(object sender, StylusEventArgs e)
        {
            if (!this.IsTouchNavigationEnabled)
            {
                return;
            }
            var x = _scrollViewer.ContentHorizontalOffset +
                    _downPoints[0].X - e.GetStylusPoints(sender as IInputElement)[0].X;

            _scrollViewer.ScrollToHorizontalOffset(x);
        }
Exemplo n.º 17
0
        private void MainWindow_StylusMove(object sender, StylusEventArgs e)
        {
            var time = DateTime.Now - _lastTime;

            var stylusPointCollection = e.GetStylusPoints(InputElement);

            foreach (var stylusPoint in stylusPointCollection)
            {
                InkRecordUserControl.InkDataModelCollection.Add(new InkDataModel(stylusPoint, time));
            }
        }
Exemplo n.º 18
0
        protected override void OnStylusMove(StylusEventArgs e)
        {
            base.OnStylusMove(e);

            if (stylusPoints == null)
            {
                stylusPoints = new StylusPointCollection();
            }

            stylusPoints.Add(e.GetStylusPoints(this, stylusPoints.Description));
        }
Exemplo n.º 19
0
    //</Snippet9>

    // Collect the stylus packets as the stylus moves.
    protected override void OnStylusMove(StylusEventArgs e)
    {
        if (stylusPoints == null)
        {
            return;
        }

        StylusPointCollection collectedPoints = e.GetStylusPoints(this, stylusPoints.Description);

        stylusPoints.Add(collectedPoints);
        AddPointsToHitTester(collectedPoints);
    }
Exemplo n.º 20
0
        private void MultiTouchInkCanvas_StylusMove(object sender, StylusEventArgs e)
        {
            var strokeVisual          = GetStrokeVisual(e.StylusDevice.Id);
            var stylusPointCollection = e.GetStylusPoints(this);

            foreach (var stylusPoint in stylusPointCollection)
            {
                strokeVisual.Add(new StylusPoint(stylusPoint.X, stylusPoint.Y));
            }

            strokeVisual.Redraw();
        }
Exemplo n.º 21
0
        private void DrawingCanvas_StylusMove(object sender, StylusEventArgs e)
        {
            if (stylusPoints == null)
            {
                return;
            }

            StylusPointCollection newStylusPoints =
                e.GetStylusPoints(this, stylusPoints.Description);

            stylusPoints.Add(newStylusPoints);
        }
Exemplo n.º 22
0
    //</Snippet10>

    // When the user lifts the stylus, create a Stroke from the
    // collected stylus points and add it to the InkPresenter.
    // When the control is selecting strokes, add the
    // point data to the IncrementalHitTester.
    protected override void OnStylusUp(StylusEventArgs e)
    {
        stylusPoints ??= new StylusPointCollection();
        StylusPointCollection collectedPoints =
            e.GetStylusPoints(this, stylusPoints.Description);

        stylusPoints.Add(collectedPoints);
        AddPointsToHitTester(collectedPoints);
        AddStrokeToPresenter();
        stylusPoints = null;

        Stylus.Capture(null);
    }
Exemplo n.º 23
0
        //
        // Ink canvas stylys move
        //
        private void InkCanvas_StylusMove(object sender, StylusEventArgs e)
        {
            double pressure = 0;
            int    count    = 0;
            StylusPointCollection points = e.GetStylusPoints(inkCanvas);

            foreach (var point in points)
            {
                pressure += point.PressureFactor;
                count++;
            }
            progressPressure.Value = pressure / count;
        }
Exemplo n.º 24
0
        //</Snippet7>

        //<Snippet8>
        protected override void OnStylusMove(StylusEventArgs e)
        {
            if (stylusPoints == null)
            {
                return;
            }

            // Add the StylusPoints that have come in since the
            // last call to OnStylusMove.
            StylusPointCollection newStylusPoints =
                e.GetStylusPoints(this, stylusPoints.Description);

            stylusPoints.Add(newStylusPoints);
        }
        private void Grid_StylusMove(object sender, StylusEventArgs e)
        {
            var pts = e.GetStylusPoints(null);

            foreach (var p in pts)
            {
                rect.Opacity = p.PressureFactor;
                textBlockCurrentPressure.Text = (p.PressureFactor * 100).ToString("#.####") + "%";
                if (Math.Abs(p.PressureFactor - lastPreesure) != 0 && Math.Abs(p.PressureFactor - lastPreesure) < minDifference)
                {
                    minDifference = Math.Abs(p.PressureFactor - lastPreesure);
                    textBlockPossiblePressure.Text = (1 / minDifference).ToString("#.#");
                }
                lastPreesure = p.PressureFactor;
            }
        }
Exemplo n.º 26
0
        private void DrawingCanvas_StylusUp(object sender, StylusEventArgs e)
        {
            if (stylusPoints == null)
            {
                return;
            }

            StylusPointCollection newStylusPoints =
                e.GetStylusPoints(this, stylusPoints.Description);

            stylusPoints.Add(newStylusPoints);

            Stroke stroke = new Stroke(stylusPoints);

            stylusPoints = null;

            Stylus.Capture(null);
        }
Exemplo n.º 27
0
        // <Snippet21>
        void inkCanvas1_StylusMove(object sender, StylusEventArgs e)
        {
            StylusPointCollection  points             = e.GetStylusPoints(inkCanvas1);
            StylusPointDescription description        = points.Description;
            StringWriter           normalPressureInfo = new StringWriter();

            if (description.HasProperty(StylusPointProperties.NormalPressure))
            {
                StylusPointPropertyInfo propertyInfo =
                    description.GetPropertyInfo(StylusPointProperties.NormalPressure);

                normalPressureInfo.WriteLine("  Guid = {0}", propertyInfo.Id.ToString());
                normalPressureInfo.Write("  Min = {0}", propertyInfo.Minimum.ToString());
                normalPressureInfo.Write("  Max = {0}", propertyInfo.Maximum.ToString());
                normalPressureInfo.Write("  Unit = {0}", propertyInfo.Unit.ToString());
                normalPressureInfo.WriteLine("  Res = {0}", propertyInfo.Resolution.ToString());
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// value that holds the last iteration point to calculate the distance.
        /// </summary>
        protected override void OnStylusMove(StylusEventArgs e)
        {
            Stroke tempStroke = new Stroke(e.GetStylusPoints((InkCanvas)e.Source));

            if (tempStroke.StylusPoints.Count <= 0)
            {
                return;
            }
            //Debug.WriteLine("Students POint: " + e.GetStylusPoints((InkCanvas)e.Source).Count);
            //add the time at which the event is thrown
            myStrokeAttManager.StrokeTime.Add(e.Timestamp);
            //provide the feedback on the speed.
            if (SpeedChecked)
            {
                GiveSpeedFeedbackAsync(tempStroke);
            }
            base.OnStylusMove(e);
        }
Exemplo n.º 29
0
        protected override void OnStylusMove(StylusEventArgs e)
        {
            base.OnStylusMove(e);

            // TJC: only take in stylus ink, not multitouch
            bool isStylus = e.StylusDevice.Id == MyRend.STYLUS_ID || e.StylusDevice.StylusButtons.Count == 2; // tip and barrel

            if (!isStylus)
            {
                //System.Console.WriteLine("MOVE TC: " + _touchCount + " " + _maxTouches);
                //if (_touchCount > 0) return; // don't capture ink if more than one touch // TJC: test
            }

            if (_stylusPoints == null)
            {
                return;
            }
            _stylusPoints.Add(e.GetStylusPoints(this, _stylusPoints.Description));
        }
Exemplo n.º 30
0
        protected override void OnStylusUp(StylusEventArgs e)
        {
            base.OnStylusUp(e);

            // TJC: only take in stylus ink, not multitouch
            bool isStylus = e.StylusDevice.Id == MyRend.STYLUS_ID || e.StylusDevice.StylusButtons.Count == 2; // tip and barrel

            if (!isStylus)
            {
                _touchCount--;
                //System.Console.WriteLine("UP TC: " + _touchCount + " " + _maxTouches);
                //if (_maxTouches > 0) return; // TJC: test

                // reset max touch once we hit 0
                if (_touchCount <= 0)
                {
                    _maxTouches = 0;
                }
            }

            // Release stylus capture.
            if (Stylus.Captured == this) // bcz: uncapturing the stylus will uncapture the mouse.  However, widgets like SelectionFeedback may have Captured just the Mouse and won't get their Up events - so don't uncapture unless the captured object is 'this'
            {
                Stylus.Capture(null);
            }
            if (_stylusPoints == null)
            {
                return;
            }
            _stylusPoints.Add(e.GetStylusPoints(this, _stylusPoints.Description));
            Stroke stroke = new Stroke(_stylusPoints);

            stroke.DrawingAttributes = _dynamicRenderer.DrawingAttributes.Clone();
            Stroq s = new Stroq(stroke);

            if (KeepStroqs)
            {
                _stroqs.Add(s);
            }
            _stylusPoints = null;

            RaiseStroqCollectedEvent(s, !isStylus || e.StylusDevice.SwitchState(InqUtils.BarrelSwitch) == StylusButtonState.Down);
        }