Esempio n. 1
0
        public override void OnMouseMove(InkCanvas inkCanvas, System.Windows.Input.MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                endPoint = e.GetPosition(inkCanvas);
                if(startPoint != endPoint)
                {
                    StylusPointCollection pts = new StylusPointCollection();
                    GetLine(pts, (s) =>
                    {
                        if (StrokeResult != null)
                            inkCanvas.Strokes.Remove(StrokeResult);

                        DrawingAttributes drawingAttributes = new DrawingAttributes
                        {
                            Color = inkCanvas.DefaultDrawingAttributes.Color,
                            Width = inkCanvas.DefaultDrawingAttributes.Width,
                            StylusTip = StylusTip.Ellipse,
                            IgnorePressure = true,
                            FitToCurve = true
                        };

                        StrokeResult = new LineStroke(s, drawingAttributes);
                        inkCanvas.Strokes.Add(StrokeResult);
                    }
                    );
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Adds a StylusPacket representing an incremental move of the hit-testing tool
        /// </summary>
        /// <param name="stylusPoints">stylusPoints</param>
        public void AddPoints(StylusPointCollection stylusPoints)
        {
            if (stylusPoints == null)
            {
                throw new System.ArgumentNullException("stylusPoints");
            }

            if (stylusPoints.Count == 0)
            {
                throw new System.ArgumentException(SR.Get(SRID.EmptyArrayNotAllowedAsArgument), "stylusPoints");
            }

            if (false == _fValid)
            {
                throw new System.InvalidOperationException(SR.Get(SRID.EndHitTestingCalled));
            }

            System.Diagnostics.Debug.Assert(_strokes != null);

            Point[] points = new Point[stylusPoints.Count];
            for (int x = 0; x < stylusPoints.Count; x++)
            {
                points[x] = (Point)stylusPoints[x];
            }

            AddPointsCore(points);
        }
Esempio n. 3
0
 public CustomStroke(StylusPointCollection col, Color strokeColor, int thickness, Color fill)
     : base(col)
 {
     this.strokeColor = strokeColor;
     this.thickness = thickness;
     this.fillColor = fill;
 }
Esempio n. 4
0
        public static string Classify(bool useRubine, float duration, bool righthandedness, List<float> SpeakerAngles, PointCollection pointHist, StylusPointCollection S, List<List<int>> hist, List<List<int>> ihist)
        {
            // Convert all parameters to format used in GestureTests
            List<Vector2> InterpretedPoints = new List<Vector2>();
            List<Vector2> StylusPoints = new List<Vector2>();
            List<Vector2> VelocityHistory = new List<Vector2>();
            List<Vector2> InverseVelocityHistory = new List<Vector2>();
            foreach(Point P in pointHist)
                InterpretedPoints.Add(new Vector2((float)P.X,(float)P.Y));
            foreach(StylusPoint P in S)
                StylusPoints.Add(new Vector2((float)P.X,(float)P.Y));
            for (int i = 0; i < hist[0].Count; i++)
            {
                VelocityHistory.Add(new Vector2(hist[0][i], hist[1][i]));
                InverseVelocityHistory.Add(new Vector2(ihist[0][i], ihist[1][i]));
            }

            // Create a new Sample, compute the features, and classify
            GS = new GestureSample(GestureTests.Types.GestureType.unknown, righthandedness,duration,SpeakerAngles,InterpretedPoints,StylusPoints,VelocityHistory,InverseVelocityHistory);
            GS.ComputeFeatures(GestureFeatures.PointsStroke);

            if (useRubine)
                return EC.Recognizer.Classify(GS).ToString();
            WriteARFF();

            Instances test = new Instances(new java.io.FileReader("outfile.arff"));
            test.setClassIndex(0);

            double clsLabel = cls.classifyInstance(test.instance(0));
            test.instance(0).setClassValue(clsLabel);

            // Return the appropriate label
            return ((GestureType2D)((int)clsLabel+1)).ToString();
        }
Esempio n. 5
0
 public Stroke Representation()
 {
     StylusPointCollection collection = new StylusPointCollection();
     foreach (var data in stylusPoints)
         collection.Add(data.Representation());
     return new Stroke(collection);
 }
Esempio n. 6
0
    private void addNextPDF()
    {

        PdfPage page = new PdfPage();
        page.Size = PageSize.A4;

        double h = SystemParameters.PrimaryScreenHeight;
        double w = SystemParameters.PrimaryScreenWidth;
        //XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
        var rateW = page.Width / w;
        var rateH = page.Height / h;

        var strokes = CanvasStroke.ToList();
        List<Point[]> pl = new List<Point[]>();
        foreach (Stroke stroke in strokes)
        {

            StylusPointCollection points = stroke.StylusPoints;
            StylusPointCollection newPoints = new StylusPointCollection();
            var pointList = points.ToList();
            foreach (StylusPoint pt in pointList)
            {

                StylusPoint newPt = new StylusPoint(pt.X * rateW, pt.Y * rateH);
                newPoints.Add(newPt);
            }
            Point[] p = (Point[])newPoints;
            pList.Add(p);
            pl.Add(p);
            CanvasStroke.Remove(stroke);
        }

        pointL.Add(pl);

    }
Esempio n. 7
0
        public static WindowsInk.Stroke ToWindowsStroke(NineInk.Stroke nineStroke)
        {
            var points = new StylusPointCollection();

            foreach (var point in nineStroke.Points)
                points.Add(new StylusPoint(point.X, point.Y, point.Pressure));

            var drwAttr = new WindowsInk.DrawingAttributes();
            var c = new Color();
            c.R = nineStroke.DrawingAttributes.Color.R;
            c.G = nineStroke.DrawingAttributes.Color.G;
            c.B = nineStroke.DrawingAttributes.Color.B;
            c.A = nineStroke.DrawingAttributes.Color.A;
            drwAttr.Color = c;

            switch (nineStroke.DrawingAttributes.Brush.Name)
            {
                case "Rectangle":
                    drwAttr.StylusTip = WindowsInk.StylusTip.Rectangle;
                    break;
                case "Ellipse":
                default:
                    drwAttr.StylusTip = WindowsInk.StylusTip.Ellipse;
                    break;
            }
            drwAttr.Height = nineStroke.DrawingAttributes.Height;
            drwAttr.Width = nineStroke.DrawingAttributes.Width;
            drwAttr.IsHighlighter = nineStroke.DrawingAttributes.IsHighlighter;

            return new WindowsInk.Stroke(points, drwAttr);
        }
Esempio n. 8
0
        //Метод, который отвечает за зеркальное отражение, как по-вертикали, так и по-горизонтали
        public void MirrorReflection(object sender, EventArgs e)
        {
            double val;
            bool horizontally = false;

            if ((sender as MenuItem).Name == "horizontal")
            {
                val = surface.ActualHeight;
                horizontally = true;
            }
            else
            {
                val = surface.ActualWidth;
            }

            for (int i = 0; i < surface.Strokes.Count; i++)
            {
                DrawingAttributes dr = surface.Strokes[i].DrawingAttributes;
                StylusPointCollection newPoints = new StylusPointCollection();
                for (int j = 0; j < surface.Strokes[i].StylusPoints.Count; j++)
                {
                    StylusPoint p = surface.Strokes[i].StylusPoints[j];
                    if (horizontally)
                    {
                        p.Y = val - p.Y;
                    }
                    else
                    {
                        p.X = val - p.X;
                    }
                    newPoints.Add(p);
                }
                surface.Strokes[i].StylusPoints = newPoints;
            }
        }
Esempio n. 9
0
File: Stroke.cs Progetto: dfr0/moon
		public bool HitTest (StylusPointCollection stylusPointCollection)
		{
			if (stylusPointCollection == null)
				throw new ArgumentException ("stylusPointCollection");

			return NativeMethods.stroke_hit_test (native, stylusPointCollection.native);
		}
Esempio n. 10
0
        public override void OnMouseMove(System.Windows.Controls.InkCanvas inkCanvas, System.Windows.Input.MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                bottomRight = e.GetPosition(inkCanvas);
                if(topLeft != bottomRight)
                {
                    StylusPointCollection pts = new StylusPointCollection();
                    GetRectangle(pts, (s) =>
                    {
                        if (StrokeResult != null)
                            inkCanvas.Strokes.Remove(StrokeResult);

                        DrawingAttributes drawingAttributes = new DrawingAttributes
                        {
                            Color = inkCanvas.DefaultDrawingAttributes.Color,
                            Width = inkCanvas.DefaultDrawingAttributes.Width,
                            StylusTip = StylusTip.Ellipse,
                            IgnorePressure = true,
                            FitToCurve = true
                        };
                        var BackgroundColor = inkCanvas.DefaultDrawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor);
                        drawingAttributes.AddPropertyData(DrawAttributesGuid.BackgroundColor, BackgroundColor);

                        StrokeResult = new RectangleStroke(s, drawingAttributes);
                        inkCanvas.Strokes.Add(StrokeResult);
                    }
                    );
                }

            }
        }
Esempio n. 11
0
        void GetRectangle(StylusPointCollection pts, Action<StylusPointCollection> exec)
        {
            pts.Add(new StylusPoint(topLeft.X, topLeft.Y));
            pts.Add(new StylusPoint(bottomRight.X, bottomRight.Y));

            exec(pts);
        }
Esempio n. 12
0
 public customStroke(StylusPointCollection pts,PaintingCanvas ink)
     : base(pts)
 {
     this.StylusPoints = pts;
     this.color = ink.colorName;
     this.size = ink.penSize;
 }
Esempio n. 13
0
        //A new stroke object named MyStroke is created. MyStroke is added to the StrokeCollection of the InkPresenter named MyIP
        private void MyIP_MouseLeftButtonDown(object sender, MouseEventArgs e)
        {
            MyIP.CaptureMouse();
            if (eraseflag == true)
            {

                StylusPointCollection MyStylusPointCollection = new StylusPointCollection();
                MyStylusPointCollection.Add(e.StylusDevice.GetStylusPoints(MyIP));
                NewStroke = new Stroke(MyStylusPointCollection);
                NewStroke.DrawingAttributes.Color = Colors.Red;
                MyIP.Strokes.Add(NewStroke); StylusPointCollection ErasePointCollection = new StylusPointCollection();


            }
            else
            {
                StylusPointCollection pointErasePoints = e.StylusDevice.GetStylusPoints(MyIP);
                StrokeCollection hitStrokes = MyIP.Strokes.HitTest(pointErasePoints);
                if (hitStrokes.Count > 0)
                {
                    foreach (Stroke hitStroke in hitStrokes)
                    {
                        MyIP.Strokes.Remove(hitStroke);
                        //undoStack.Push(hitStroke);
                        //undoStateBufferStack.Push(true);
                    }
                }
            }
        }
Esempio n. 14
0
 public TouchPoint2(TouchInfo info, UIElement source, StylusPointCollection stylusPoints)
 {
     this.Source = source;
     Stroke = new Stroke(stylusPoints);
     TouchDeviceId = info.TouchDeviceId;
     StartTime = DateTime.Now;
     UpdateTouchInfo(info);
 }
Esempio n. 15
0
        public static void up(MouseButtonEventArgs e, InkPresenter inkCanvas, Grid LayoutRoot)
        {
            int clickedLayer = Common.hitTestLayer(e, inkCanvas);
            StylusPointCollection spc = new StylusPointCollection();

            checkIfStrokeSelected(e, inkCanvas, spc);

            checkIfLayerSelected(LayoutRoot, clickedLayer);
        }
Esempio n. 16
0
        private static void checkIfStrokeSelected(MouseButtonEventArgs e, InkPresenter inkCanvas, StylusPointCollection spc)
        {
            spc.Add(new StylusPoint(e.GetPosition(inkCanvas).X, e.GetPosition(inkCanvas).Y));

            if (inkCanvas.Strokes.HitTest(spc).Count > 0)
            {
                removeSelectedStroke(inkCanvas, spc);
            }

            return;
        }
Esempio n. 17
0
        private bool IsEnclosedAreaWithinRange(StylusPointCollection stylusPointCollection)
        {
            // TODO: Move the magic number to configuration
            Point[] points = stylusPointCollection.ToFilteredPoints(5);

            double area  = ConvexHullArea.GetArea(points);

            if (area >= _data.Min && area <= _data.Max)
                return true;
            else
                return false;
        }
Esempio n. 18
0
 private void myInkPresenter_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     //捕获鼠标焦点
     myInkPresenter.CaptureMouse();
     myPointCollection = new StylusPointCollection();
     myPointCollection.Add(e.StylusDevice.GetStylusPoints(myInkPresenter));
     currentStroke = new Stroke(myPointCollection);
     //设置画笔属性
     currentStroke.DrawingAttributes.Color = currentColor;
     currentStroke.DrawingAttributes.Height = sliderThickness.Value;
     currentStroke.DrawingAttributes.Width = sliderThickness.Value;
     myInkPresenter.Strokes.Add(currentStroke);
 }
Esempio n. 19
0
        /// <summary>
        /// Construct bezier control points from points
        /// </summary>
        /// <param name="stylusPoints">Original StylusPointCollection</param>
        /// <param name="fitError">Fitting error</param>
        /// <returns>Whether the algorithm succeeded</returns>
        internal bool ConstructBezierState(StylusPointCollection stylusPoints, double fitError)
        {
            // If the point count is zero, the curve cannot be constructed
            if ((null == stylusPoints) || (stylusPoints.Count == 0))
                return false;

            // Compile list of distinct points and their nodes
            CuspData dat = new CuspData();
            dat.Analyze(stylusPoints, 
                        fitError /*typically zero*/);

            return ConstructFromData(dat, fitError);
        }
 public void Deserialize(XmlNode xmlNode, FlowDocument flowDocument)
 {
     var inkCanvas = new InkCanvasEx();
     foreach (XmlNode strokeNode in xmlNode.ChildNodes)
     {
         var points = new StylusPointCollection();
         foreach (XmlNode pointNode in strokeNode.ChildNodes)
         {
             points.Add(new StylusPoint(Double.Parse(pointNode.Attributes["X"].InnerText),
                 Double.Parse(pointNode.Attributes["Y"].InnerText)));
         }
         inkCanvas.Strokes.Add(new Stroke(points)); //TODO DrawingAttributes
     }
     flowDocument.Blocks.Add(new DrawerBlock { Child = new DrawerControl { Strokes = inkCanvas.Strokes }});
 }
Esempio n. 21
0
        public static void down(MouseButtonEventArgs e, InkPresenter inkCanvas, Grid LayoutRoot)
        {
            dragStarted = true;
            inkCanvas.CaptureMouse();

            clickedLayer = Common.hitTestLayer(e, inkCanvas);
            initialPos = e.GetPosition(inkCanvas);

            StylusPointCollection spc = new StylusPointCollection();
            spc.Add(new StylusPoint(e.GetPosition(inkCanvas).X, e.GetPosition(inkCanvas).Y));

            hitCount = inkCanvas.Strokes.HitTest(spc).Count;

            System.Diagnostics.Debug.WriteLine("layer " + clickedLayer);

            if (clickedLayer != -1)
            {

                //Calculate offset of left, right, top, bottom
                calculateOffset(e, inkCanvas);

                //System.Diagnostics.Debug.WriteLine("maxLeft " + MainPage.layerList[clickedLayer].imageToBorderDist[LEFT]);
                //System.Diagnostics.Debug.WriteLine("offSetLeft " + offSetLeft);
                //System.Diagnostics.Debug.WriteLine("positionY" + e.GetPosition(inkCanvas).Y);
                //System.Diagnostics.Debug.WriteLine("maxTop " + MainPage.layerList[clickedLayer].imageToBorderDist[TOP]);
                //System.Diagnostics.Debug.WriteLine("offSetTop " + offSetTop);

                //if the clickedLayer's image is out of bound
                if (clickedLayer != -1 && MainPage.layerList[clickedLayer].imgBackup != null)
                {
                    replaceMovingImgWithBackupImg(LayoutRoot);

                }
                else
                {
                    //temporarly save image in image backup
                    imageBackup = new WriteableBitmap((BitmapSource)MainPage.layerList[clickedLayer].img.Source);
                }

            }

            //Line clicked
            if (hitCount > 0)
            {
                moveInkToNewInkPresenter(inkCanvas, LayoutRoot, spc);
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Constructs internal data structure from points for doing operations like
        /// cusp detection or tangent computation
        /// </summary>
        /// <param name="stylusPoints">Points to be analyzed</param>
        /// <param name="rSpan">Distance between two consecutive distinct points</param>
        internal void Analyze(StylusPointCollection stylusPoints, double rSpan)
        {
            // If the count is less than 1, return
            if ((null == stylusPoints) || (stylusPoints.Count == 0))
                return;

            _points = new List<CDataPoint>(stylusPoints.Count);
            _nodes = new List<double>(stylusPoints.Count);

            // Construct the lists of data points and nodes
            _nodes.Add(0);
            CDataPoint cdp0 = new CDataPoint();
            cdp0.Index = 0;
            //convert from Avalon to Himetric
            Point point = (Point)stylusPoints[0];
            point.X *= StrokeCollectionSerializer.AvalonToHimetricMultiplier;
            point.Y *= StrokeCollectionSerializer.AvalonToHimetricMultiplier;
            cdp0.Point = point;
            _points.Add(cdp0);

            //drop duplicates
            int index = 0;
            for (int i = 1; i < stylusPoints.Count; i++)
            {
                if (!DoubleUtil.AreClose(stylusPoints[i].X, stylusPoints[i - 1].X) ||
                    !DoubleUtil.AreClose(stylusPoints[i].Y, stylusPoints[i - 1].Y))
                {
                    //this is a unique point, add it
                    index++;

                    CDataPoint cdp = new CDataPoint();
                    cdp.Index = index;

                    //convert from Avalon to Himetric
                    Point point2 = (Point)stylusPoints[i];
                    point2.X *= StrokeCollectionSerializer.AvalonToHimetricMultiplier;
                    point2.Y *= StrokeCollectionSerializer.AvalonToHimetricMultiplier;
                    cdp.Point = point2;

                    _points.Insert(index, cdp);
                    _nodes.Insert(index, _nodes[index - 1] + (XY(index) - XY(index - 1)).Length);
                }
            }
 
            SetLinks(rSpan);
        }
Esempio n. 23
0
        // This is called on the application thread.
        protected override void OnStylusUpProcessed(object callbackData, bool targetVerified)
        {
            // Check that the element actually receive the OnStylusUp input.
            if (targetVerified)
            {
                StylusPointCollection strokePoints = callbackData as StylusPointCollection;

                if (strokePoints == null)
                {
                    return;
                }

                // Raise the StrokeRendered event so the consumer of the plugin can
                // add the filtered stroke to its StrokeCollection.
                StrokeRenderedEventArgs e = new StrokeRenderedEventArgs(strokePoints);
                OnStrokeRendered(e);
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Creates a default enumerator for a given stroke
        /// If using the strokes drawing attributes, pass stroke.DrawingAttributes for the second
        /// argument.  If using an overridden DA, use that instance.
        /// </summary>
        internal static StrokeNodeIterator GetIterator(StylusPointCollection stylusPoints, DrawingAttributes drawingAttributes)
        {
            if (stylusPoints == null)
            {
                throw new System.ArgumentNullException("stylusPoints");
            }
            if (drawingAttributes == null)
            {
                throw new System.ArgumentNullException("drawingAttributes");
            }

            StrokeNodeOperations operations =
                StrokeNodeOperations.CreateInstance(drawingAttributes.StylusShape);

            bool usePressure = !drawingAttributes.IgnorePressure;

            return new StrokeNodeIterator(stylusPoints, operations, usePressure);
        }
Esempio n. 25
0
        private StylusPointCollection SetStylusPointDescription(StylusPointCollection stylusPointCollection)
        {
            StylusPointDescription stylusPointDescription;

            stylusPointDescription = this.StylusPointDescription;
            StylusPointCollection stylusPointCollection2;

            stylusPointCollection2 = new StylusPointCollection(stylusPointDescription, stylusPointCollection.Count);
            if (stylusPointDescription != null)
            {
                foreach (var stylusPoint in stylusPointCollection)
                {
                    var item = new StylusPoint(stylusPoint.X, stylusPoint.Y, stylusPoint.PressureFactor, stylusPointDescription, new int[StylusPointDescription.PropertyCount - 3]);
                    stylusPointCollection2.Add(item);
                }
            }
            return(stylusPointCollection2);
        }
        protected override void OnDraw(DrawingContext drawingContext, StylusPointCollection stylusPoints, Geometry geometry, Brush fillBrush)
        {
            var owner  = this.Element;
            var visual = GetContainerVisual();

            visual?.Children.Clear();
            if (owner is InkCanvas inkCanvas)
            {
                // 如果有选中的Stroke 那么不显示
                if (inkCanvas.GetSelectedStrokes().Any())
                {
                    return;
                }

                // 没有选中的 画矩形选择框
                drawingContext.DrawRectangle(Pen.Brush, Pen, new Rect(_downPoint, (Point)stylusPoints[stylusPoints.Count - 1]));
            }
        }
Esempio n. 27
0
            public void RenderPackets(StylusPointCollectionInfo stylusPointCollectionInfo)
            {
                StrokeInfo    strokeInfo    = stylusPointCollectionInfo.StrokeInfo;
                InkRenderInfo inkRenderInfo = strokeInfo.InkRenderInfo;

                foreach (var stylusPoint in stylusPointCollectionInfo.StylusPlugInCollection)
                {
                    StylusPointCollection stylusPointCollection = inkRenderInfo.StrokeTipBuilder.AddPoint(stylusPoint);
                    if (stylusPointCollection != null)
                    {
                        StrokeVisual strokeVisual = new StrokeVisual(strokeInfo.FillSolidColorBrush, strokeInfo.DrawingAttributes, stylusPointCollection);
                        inkRenderInfo.ContainerVisual.Children.Add(strokeVisual);
                        inkRenderInfo.StrokeVisualList.AddLast(strokeVisual);
                        strokeVisual.Redraw();
                    }
                }
                // inkRenderInfo.StrokeTipBuilder.Redraw();
            }
Esempio n. 28
0
        public ShapeStroke(StylusPointCollection pts) : base(pts)
        {
            guid = Guid.NewGuid();
            name = "This is a stroke";

            Point       lastPoint   = pts[pts.Count - 1].ToPoint();
            Coordinates coordinates = new Coordinates(lastPoint.X, lastPoint.Y);

            shapeStyle = new ShapeStyle(coordinates, 1, 1, 0, "#000000", 0, "#FFFFFF");

            while (StylusPoints.Count > 1)
            {
                StylusPoints.RemoveAt(0);
            }

            linksTo   = new List <string>();
            linksFrom = new List <string>();
        }
        private WriteableBitmap GetImageInternal(Size scale, Rect signatureBounds, Size imageSize, float strokeWidth, Color strokeColor, Color backgroundColor)
        {
            var presenter = new InkPresenter
            {
                Width      = imageSize.Width / scale.Width,
                Height     = imageSize.Height / scale.Height,
                Strokes    = new StrokeCollection(),
                Background = new SolidColorBrush(backgroundColor)
            };

            foreach (var stroke in inkPresenter.Strokes)
            {
                Stroke tempStroke;
                if (signatureBounds.X != 0 || signatureBounds.Y != 0)
                {
                    var newCollection = new StylusPointCollection();
                    foreach (var point in stroke.StylusPoints)
                    {
                        var newPoint = new StylusPoint
                        {
                            X = point.X - signatureBounds.X,
                            Y = point.Y - signatureBounds.Y
                        };
                        newCollection.Add(newPoint);
                    }

                    tempStroke = new Stroke(newCollection);
                }
                else
                {
                    tempStroke = new Stroke(stroke.StylusPoints);
                }

                tempStroke.DrawingAttributes.Color  = strokeColor;
                tempStroke.DrawingAttributes.Width  = lineWidth;
                tempStroke.DrawingAttributes.Height = lineWidth;
                presenter.Strokes.Add(tempStroke);
                tempStroke = null;
            }

            return(new WriteableBitmap(presenter, new ScaleTransform {
                ScaleX = scale.Width, ScaleY = scale.Height
            }));
        }
Esempio n. 30
0
        public void drawLine(int nPenStatus, int x, int y, float nCompress)
        {
            Point p = new Point(x, y);

            if (!pointIsInvalid(nPenStatus, p))
            {
                return;
            }

            if (nPenStatus == 0)//离笔
            {
                IsHaveLastPoint = false;
                startCount      = 0;
            }
            else
            {
                startCount++;
                if (!IsHaveLastPoint)
                {
                    stylusPointCollection = new StylusPointCollection();
                    stylusPointCollection.Add(new StylusPoint(x, y, 0.1f));
                    Console.WriteLine("draw4:{0},{1},{2}", x, y, nCompress);
                    stroke = new Stroke(stylusPointCollection);
                    stroke.DrawingAttributes = new DrawingAttributes {
                        Width = brushWidth, Height = brushWidth, Color = Color.FromRgb(0, 0, 0)
                    };
                    IsHaveLastPoint = true;
                    ic.Strokes.Add(stroke);
                }
                else
                {
                    if (startCount < 3)
                    {
                        stylusPointCollection.Add(new StylusPoint(x, y, 0.1f));
                    }
                    else
                    {
                        stylusPointCollection.Add(new StylusPoint(x, y, nCompress));
                    }

                    Console.WriteLine("draw4:{0},{1},{2}", x, y, nCompress);
                }
            }
        }
Esempio n. 31
0
        /// <summary>
        /// Check whether a certain percentage of the stroke is within the Rect passed in.
        /// </summary>
        /// <param name="bounds"></param>
        /// <param name="percentageWithinBounds"></param>
        /// <returns></returns>
        public bool HitTest(Rect bounds, int percentageWithinBounds)
        {
            if ((percentageWithinBounds < 0) || (percentageWithinBounds > 100))
            {
                throw new System.ArgumentOutOfRangeException("percentageWithinBounds");
            }

            if (percentageWithinBounds == 0)
            {
                return(true);
            }

            StrokeInfo strokeInfo = null;

            try
            {
                strokeInfo = new StrokeInfo(this);

                StylusPointCollection stylusPoints = strokeInfo.StylusPoints;
                double target = strokeInfo.TotalWeight * percentageWithinBounds / 100.0f - PercentageTolerance;

                for (int i = 0; i < stylusPoints.Count; i++)
                {
                    if (true == bounds.Contains((Point)stylusPoints[i]))
                    {
                        target -= strokeInfo.GetPointWeight(i);
                        if (DoubleUtil.LessThanOrClose(target, 0d))
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }
            finally
            {
                if (strokeInfo != null)
                {
                    //detach from event handlers, or else we leak.
                    strokeInfo.Detach();
                }
            }
        }
Esempio n. 32
0
        //描く処理(ペン用)
        private void inkCanvas1_StylusMove(object sender, StylusEventArgs e)
        {
            //消しゴムモードなら抜け出す
            if (inkCanvas1.EditingMode == InkCanvasEditingMode.EraseByPoint)
            {
                return;
            }

            UIElement el = sender as UIElement;

            Console.WriteLine("dragging = " + dragging + " in mousemove");

            //自由線モード
            if (dragging && isFreeLine)
            {
                points.Add(e.GetPosition(el));
                counter++;

                //点の情報を集め、始点と現在の点をむすぶ
                StylusPointCollection spc = new StylusPointCollection();
                spc.Add(new StylusPoint(prevP.X, prevP.Y));
                spc.Add(new StylusPoint(e.GetPosition(el).X, e.GetPosition(el).Y));
                Stroke stroke = new Stroke(spc, inkDAs.Last());
                inkCanvas1.Strokes.Add(stroke);

                prevP = e.GetPosition(el);
            }

            //直線モード
            else if (!isFreeLine && dragging)
            {
                inkCanvas1.Strokes.Clear();
                drawAll();

                //点の情報を集め、始点と現在の点をむすぶ
                StylusPointCollection spc = new StylusPointCollection();
                spc.Add(new StylusPoint(startP.X, startP.Y));
                spc.Add(new StylusPoint(e.GetPosition(el).X, e.GetPosition(el).Y));
                Stroke stroke = new Stroke(spc, inkDAs.Last());
                inkCanvas1.Strokes.Add(stroke);

                counter++;
            }
        }
Esempio n. 33
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);
        }
 // Token: 0x06006DB7 RID: 28087 RVA: 0x001F85E8 File Offset: 0x001F67E8
 protected override void StylusInputContinue(StylusPointCollection stylusPoints, bool userInitiated)
 {
     if (this._lassoHelper != null)
     {
         List <Point> list = new List <Point>();
         for (int i = 0; i < stylusPoints.Count; i++)
         {
             list.Add((Point)stylusPoints[i]);
         }
         Point[] array = this._lassoHelper.AddPoints(list);
         if (array.Length != 0)
         {
             this._incrementalLassoHitTester.AddPoints(array);
             return;
         }
     }
     else if (!this._disableLasso)
     {
         bool         flag  = false;
         List <Point> list2 = new List <Point>();
         for (int j = 0; j < stylusPoints.Count; j++)
         {
             Point point = (Point)stylusPoints[j];
             if (!flag)
             {
                 double lengthSquared = (point - this._startPoint).LengthSquared;
                 if (DoubleUtil.GreaterThan(lengthSquared, 49.0))
                 {
                     list2.Add(point);
                     flag = true;
                 }
             }
             else
             {
                 list2.Add(point);
             }
         }
         if (flag)
         {
             this.StartLasso(list2);
         }
     }
 }
        protected void Update( object sender, EventArgs e )
        {
            paintCanvas.Strokes.Clear();
            windowWidth = (float)this.Width;
            windowHeight = (float)this.Height;

            Leap.Frame frame = leap.Frame();
            InteractionBox interactionBox = leap.Frame().InteractionBox;

            foreach ( Pointable pointable in leap.Frame().Pointables ) {
                // ここから追加
                // 伸びている指、ツール以外は無視する
                //if ( !pointable.IsExtended ) {
                //    continue;
                //}
                // ここまで追加

                Leap.Vector normalizedPosition =
                    interactionBox.NormalizePoint( pointable.StabilizedTipPosition );
                float tx = normalizedPosition.x * windowWidth;
                float ty = windowHeight - normalizedPosition.y * windowHeight;

                int alpha = 255;
                if ( (pointable.TouchDistance > 0 && pointable.TouchZone != Pointable.Zone.ZONENONE ) ) {
                    alpha = 255 - (int)(255 * pointable.TouchDistance);
                    touchIndicator.Color = Color.FromArgb( (byte)alpha, 0x0, 0xff, 0x0 );
                }
                else if ( pointable.TouchDistance <= 0 ) {
                    alpha = -(int)(255 * pointable.TouchDistance);
                    touchIndicator.Color = Color.FromArgb( (byte)alpha, 0xff, 0x0, 0x0 );
                }
                else {
                    alpha = 50;
                    touchIndicator.Color = Color.FromArgb( (byte)alpha, 0x0, 0x0, 0xff );
                }

                StylusPoint touchPoint = new StylusPoint( tx, ty );
                StylusPointCollection tips =
                    new StylusPointCollection( new StylusPoint[] { touchPoint } );
                Stroke touchStroke = new Stroke( tips, touchIndicator );
                paintCanvas.Strokes.Add( touchStroke );
            }
        }
Esempio n. 36
0
        private void OnMouseDown(object sender, MouseButtonEventArgs e)
        {
            inkPresenter.CaptureMouse();

            var points = new StylusPointCollection();

            points.Add(e.StylusDevice.GetStylusPoints(inkPresenter));

            currentStroke = new Stroke(points);
            currentStroke.DrawingAttributes = new DrawingAttributes
            {
                Color        = StrokeColor,
                OutlineColor = StrokeColor,
                Width        = StrokeWidth,
                Height       = StrokeWidth,
            };

            inkPresenter.Strokes.Add(currentStroke);
        }
        public string ToText(IEnumerable <PdfAnnotation> annots)
        {
            if (annots == null)
            {
                return(null);
            }
            var actualStrokes = new StrokeCollection();

            foreach (var annot in annots)
            {
                var stylusPoints = new StylusPointCollection();
                for (int i = 0; i < annot.Rect.Length - 1; i += 2)
                {
                    stylusPoints.Add(new StylusPoint(annot.Rect[i], annot.Rect[i + 1]));;
                }
                actualStrokes.Add(new Stroke(stylusPoints));
            }
            return(ToText(actualStrokes));
        }
Esempio n. 38
0
        /// <summary>
        /// 移动批量关键帧动画类
        /// </summary>
        /// <param name="spiralSummarization"></param>
        /// <param name="operationId"></param>
        /// <param name="insertIndex"></param>
        /// <param name="fromKeyPointIndexes"></param>
        /// <param name="toKeyPointIndexes"></param>
        /// <param name="keyFrames"></param>
        public MoveKeyFrame(SpiralSummarization spiralSummarization, int operationId, int insertIndex, List <int> fromKeyPointIndexes, List <int> toKeyPointIndexes, List <KeyFrame> keyFrames)//, int index, KeyFrame keyFrame, int startIndex, int endIndex, double duration,bool isInsert)
        {
            if (spiralSummarization != null)
            {
                spiralSummarization.InkCollector.IsShowUnbrokenKeyFrame = false;
            }
            this.operationId         = operationId;
            this.fromKeyPointIndexes = fromKeyPointIndexes;
            this.toKeyPointIndexes   = toKeyPointIndexes;
            this.keyFrames           = keyFrames;
            this.spiralSummarization = spiralSummarization;
            this.insertIndex         = insertIndex;
            showCount             = keyFrames.Count;
            this.showSpiralStroke = spiralSummarization.ShowSpiralStroke;
            this.points           = spiralSummarization.Points;
            for (int i = 1; i < showCount; i++)
            {
                int movePointCount = Math.Abs(fromKeyPointIndexes[i] - toKeyPointIndexes[i]);
                if (movePointCount > maxMovePointCount)
                {
                    maxMovePointCount      = movePointCount;
                    maxMovePointCountIndex = i;
                }
                else if (movePointCount < minMovePointCount && movePointCount > 0)
                {
                    minMovePointCount = movePointCount;
                }
            }

            for (int i = 1; i < showCount; i++)
            {
                int movePointCount        = Math.Abs(fromKeyPointIndexes[i] - toKeyPointIndexes[i]);
                int movePointCountPerTime = (int)Math.Floor((double)movePointCount / minMovePointCount);
                int restPointCount        = movePointCount % minMovePointCount;
                restPointCountList.Add(restPointCount);
                int moveTime = (int)Math.Ceiling((double)movePointCount / movePointCountPerTime);
                if (moveTime > maxMoveTime)
                {
                    maxMoveTime = moveTime;
                }
                movePointCountPerTimes.Add(movePointCountPerTime);
            }
        }
        public void DrawTextInRectangle(object sender, RoutedEventArgs e)
        {
            StylusPointCollection pts = new StylusPointCollection();

            pts.Add(new StylusPoint(100, 100));

            pts.Add(new StylusPoint(100, 300));

            pts.Add(new StylusPoint(300, 300));

            pts.Add(new StylusPoint(300, 100));

            pts.Add(new StylusPoint(100, 100));

            CustomStroke st = new CustomStroke(pts);

            st.DrawingAttributes.Color = Colors.Red;
            inkCanvas1.Strokes.Add(st);
        }
Esempio n. 40
0
        /// <summary>
        /// 清空
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            if (!ic.CollectingInk)
            {
                Strokes strokesToDelete = ic.Ink.Strokes;
                ic.Ink.DeleteStrokes(strokesToDelete);
                ic.Ink.DeleteStrokes(); //清除手写区域笔画;
                ink_here.Refresh();     //刷新手写区域

                richTextBox1.Clear();

                signPoints = new List <StylusPoint>();
                strokes    = new StrokeCollection();
                strokeColl = new StylusPointCollection();
                bpoint     = new string[3] {
                    "0", "0", "0"
                };
            }
        }
Esempio n. 41
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();
        }
Esempio n. 42
0
        //private void cSlide1(object sender, RoutedPropertyChangedEventArgs<double> e)
        //{
        //    StylusPointCollection allPoints = new StylusPointCollection();

        //    foreach (Stroke stroke in inkIn1.Strokes)
        //    {
        //        allPoints.Add(stroke.StylusPoints);
        //    }

        //    ComplexStroke cStroke = new ComplexStroke(allPoints);


        //    inkReconstruction1.Strokes = new StrokeCollection();
        //    inkReconstruction1.Strokes.Add(cStroke.ReconstructedStroke((int)coefficientSlider1.Value));

        //}

        private void cSlide1(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            StylusPointCollection allPoints = new StylusPointCollection();

            foreach (Stroke stroke in inkIn1.Strokes)
            {
                allPoints.Add(stroke.StylusPoints);
            }

            ComplexStroke cStroke = new ComplexStroke(allPoints);

            inkReconstruction1.Children.Clear();

            Stroke reconstruct = cStroke.ReconstructedStroke((int)coefficientSlider1.Value);

            DrawStrokePoints(reconstruct, inkReconstruction1, Brushes.Red);
            inkReconstruction1.Strokes = new StrokeCollection();
            inkReconstruction1.Strokes.Add(cStroke.ReconstructedStroke((int)coefficientSlider1.Value));
        }
Esempio n. 43
0
 public override Point Draw(Point first, MyInkData tool, DrawingContext dc, StylusPointCollection points)
 {
     for (int i = 0; i < points.Count; i++)
     {
         Point  pt = (Point)points[i];
         Vector v  = Point.Subtract(pt, first);
         Size   size;
         double distance = GetStylusInkDistance(tool, out size);
         if (v.Length >= distance)
         {
             double x    = pt.X - size.Width;
             double y    = pt.Y - size.Height;
             Rect   rect = new Rect(x, y, 2 * size.Width, 2 * size.Height);
             dc.DrawImage(bi, rect);
             first = pt;
         }
     }
     return(first);
 }
Esempio n. 44
0
        //public void AddStroke(System.Windows.Ink.Stroke stroke)
        //{

        //    int[] packets = stroke.StylusPoints.ToHiMetricArray();
        //    Guid[] packetDescription = stroke.StylusPoints.Description.GetStylusPointPropertyIds();

        //    _inkAnalyzerBase.AddStroke(_strokeId++, packets, packetDescription);

        //}

        void StylusPointCollectionSnippets()
        {
            //MessageBox.Show("hi");
            //<Snippet20>
            StylusPointCollection points = new StylusPointCollection(new Point[]
            {
                new Point(100, 100),
                new Point(100, 200),
                new Point(200, 250),
                new Point(300, 300)
            });
            //</Snippet20>
            //points.RemoveAt(0);
            //points.RemoveAt(0);
            StylusPoint point = new StylusPoint(400, 300);
            //points.Insert(3, point);

            //points.Insert(2, point);
        }
Esempio n. 45
0
        public void Clear()
        {
            StylusPointCollection spc = new StylusPointCollection();

            foreach (Stroke st in canvas.Strokes)
            {
                spc.Add(st.StylusPoints[0]);
            }

            if (spc.Count != 0)
            {
                RedoList.Add(new Stroke(spc));
                UndoPoints.Add(spc.Count);
                ActionHistory.Add(Actions.Clear);
            }

            this.canvas.Strokes.Clear();
            dirty = true;
        }
Esempio n. 46
0
        public override void MakeShape()
        {
            StylusPointCollection pts = new StylusPointCollection();

            pts.Add(new StylusPoint(this.Center.X - this.Width / 2, this.Center.Y - this.Height / 2));
            pts.Add(new StylusPoint(pts[0].X + this.Width, pts[0].Y));
            pts.Add(new StylusPoint(pts[0].X + this.Width, pts[0].Y + this.Height));
            pts.Add(new StylusPoint(pts[0].X, pts[0].Y + this.Height));
            pts.Add(new StylusPoint(pts[0].X, pts[0].Y));

            this.StylusPoints = pts;

            if (this.CurrentRotation != 0)
            {
                int rotation = this.CurrentRotation;
                this.CurrentRotation = 0;
                this.SetRotation(rotation);
            }
        }
 // Token: 0x06006D65 RID: 28005 RVA: 0x001F6864 File Offset: 0x001F4A64
 protected override void StylusInputBegin(StylusPointCollection stylusPoints, bool userInitiated)
 {
     this._incrementalStrokeHitTester = base.InkCanvas.Strokes.GetIncrementalStrokeHitTester(base.InkCanvas.EraserShape);
     if (InkCanvasEditingMode.EraseByPoint == this._cachedEraseMode)
     {
         this._incrementalStrokeHitTester.StrokeHit += this.OnPointEraseResultChanged;
     }
     else
     {
         this._incrementalStrokeHitTester.StrokeHit += this.OnStrokeEraseResultChanged;
     }
     this._stylusPoints = new StylusPointCollection(stylusPoints.Description, 100);
     this._stylusPoints.Add(stylusPoints);
     this._incrementalStrokeHitTester.AddPoints(stylusPoints);
     if (InkCanvasEditingMode.EraseByPoint == this._cachedEraseMode)
     {
         base.EditingCoordinator.InvalidateBehaviorCursor(this);
     }
 }
Esempio n. 48
0
        protected override void OnStylusDown(StylusDownEventArgs e)
        {
            Stylus.Capture(this);

            //Get the StylusPoints that have come in so far
            StylusPointCollection newStylusPoints = e.GetStylusPoints(this);

            // Allocate memory for the StylusPointsCollection and
            // add the StylusPoints that have come in so far
            //stylusPoints = new StylusPointCollection(newStylusPoints.Description);
            //stylusPoints.Add(newStylusPoints);

            //Create a new StylusPointCollection using the StylusPointDescription
            //from the stylus points in the StylusDownEventArgs.
            stylusPoints = new StylusPointCollection();
            StylusPointCollection eventPoints = e.GetStylusPoints(this, stylusPoints.Description);

            stylusPoints.Add(eventPoints);
        }
Esempio n. 49
0
        /// <summary>
        /// Handles the MouseLeftButtonDown event of the InkPresenterCommentText control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Input.MouseButtonEventArgs"/> instance containing the event data.</param>
        private void InkPresenterCommentText_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            this.InkPresenterCommentText.CaptureMouse();

            if (this.editingMode == InkEditingMode.Ink)
            {
                this.currentStroke = new Stroke
                {
                    DrawingAttributes = { Color = this.currentColor }
                };
                this.currentStroke.StylusPoints.Add(e.StylusDevice.GetStylusPoints(this.InkPresenterCommentText));
                this.InkPresenterCommentText.Strokes.Add(this.currentStroke);
            }

            if (this.editingMode == InkEditingMode.Erase)
            {
                this.pointsToErase = e.StylusDevice.GetStylusPoints(this.InkPresenterCommentText);
            }
        }
        private void DrawPolygon(
            Color color,
            params Point[] points)
        {
            StylusPointCollection stylusPointCollection = new StylusPointCollection();

            foreach (Point point in points)
            {
                stylusPointCollection.Add(new StylusPoint(point.X, point.Y));
            }

            Stroke stroke = new Stroke(stylusPointCollection);

            stroke.DrawingAttributes.Color  = color;
            stroke.DrawingAttributes.Width  = 1;
            stroke.DrawingAttributes.Height = 1;

            _surface.Strokes.Add(stroke);
        }
Esempio n. 51
0
        /// <summary>
        /// 画对顺时针称螺旋线
        /// </summary>
        private void drawSpiralClockwise()
        {
            StylusPointCollection spc = new StylusPointCollection();//螺旋线上点集合
            double x        = 0;
            double y        = 0;
            double r        = 0;
            double max      = Math.PI * 15;
            double interval = Math.PI / 180;

            StylusPointCollection spcCenter = new StylusPointCollection();

            for (double i = 0; i < Math.PI / 2; i += interval)
            {
                r = newSpiralWidth * i;
                x = center.X + r * Math.Cos(i);
                y = center.Y + r * Math.Sin(i);
                StylusPoint sp = new StylusPoint(x, y);
                spcCenter.Add(sp);
            }
            Stroke sCenter = new Stroke(spcCenter);

            sCenter.DrawingAttributes.Color  = Color.FromArgb(255, 255, 255, 0);
            sCenter.DrawingAttributes.Width  = SpiralStrokeWidth;
            sCenter.DrawingAttributes.Height = SpiralStrokeWidth;
            _inkCanvas.Strokes.Add(sCenter);
            for (double i = Math.PI / 2; i < max; i += interval)
            {
                r = newSpiralWidth * i;
                x = center.X + r * Math.Cos(i);
                y = center.Y + r * Math.Sin(i);
                StylusPoint sp = new StylusPoint(x, y);
                spc.Add(sp);
            }
            Stroke s = new Stroke(spc);

            //s.DrawingAttributes.FitToCurve = true;
            s.DrawingAttributes.Color  = Color.FromArgb(0, 255, 255, 0);
            s.DrawingAttributes.Width  = SpiralStrokeWidth;
            s.DrawingAttributes.Height = SpiralStrokeWidth;
            spiralStroke = s;
            _inkCanvas.Strokes.Add(spiralStroke);
        }
Esempio n. 52
0
        private void StrokeRectConvert(System.Windows.Ink.Stroke stroke)
        {
            StylusPointCollection ptsRect = new StylusPointCollection();
            StylusPointCollection pts     = stroke.StylusPoints;

            double minX = double.MaxValue;
            double minY = minX;
            double maxX = double.MinValue;
            double maxY = maxX;

            //find bounding area
            foreach (StylusPoint pt in pts)
            {
                if (pt.X > maxX)
                {
                    maxX = pt.X;
                }
                if (pt.X < minX)
                {
                    minX = pt.X;
                }

                if (pt.Y > maxY)
                {
                    maxY = pt.Y;
                }
                if (pt.Y < minY)
                {
                    minY = pt.Y;
                }
            }
            //stroke four corners of the rect
            ptsRect.Add(new StylusPoint(minX, minY));
            ptsRect.Add(new StylusPoint(minX, maxY));
            ptsRect.Add(new StylusPoint(maxX, maxY));
            ptsRect.Add(new StylusPoint(maxX, minY));
            ptsRect.Add(new StylusPoint(minX, minY));
            stroke.StylusPoints = ptsRect;

            //no smoothing
            stroke.DrawingAttributes.FitToCurve = false;
        }
Esempio n. 53
0
        private void HandleInteraction(object clientData, RawStylusSystemGestureInputReport originalReport)
        {
            RawStylusSystemGestureInputReport report = new RawStylusSystemGestureInputReport(
                InputMode.Foreground,
                Environment.TickCount,
                CriticalActiveSource,
                () => { return(PointerTabletDevice.StylusPointDescription); },
                TabletDevice.Id,
                Id,
                originalReport.SystemGesture,
                originalReport.GestureX,
                originalReport.GestureY,
                originalReport.ButtonState)
            {
                StylusDevice = StylusDevice,
            };

            // For a flick, update the points in the stylus device to the flick location.
            // This forces processing of the stylus over to use the initial flick location
            // instead of the last WM_POINTER message location allowing command processing to
            // be done on the flick location itself.
            if (report.SystemGesture == SystemGesture.Flick)
            {
                StylusPoint flickPoint = _currentStylusPoints[_currentStylusPoints.Count - 1];

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

                _currentStylusPoints = new StylusPointCollection(flickPoint.Description,
                                                                 flickPoint.GetPacketData(),
                                                                 GetTabletToElementTransform(null),
                                                                 Matrix.Identity);
            }

            InputReportEventArgs irea = new InputReportEventArgs(StylusDevice, report)
            {
                RoutedEvent = InputManager.PreviewInputReportEvent,
            };

            // Now send the input report
            InputManager.UnsecureCurrent.ProcessInput(irea);
        }
Esempio n. 54
0
        public StylusPointCollection getCurve(StylusPoint start, StylusPoint end)
        {
            StylusPointCollection collection = new StylusPointCollection();

            if (start.X > end.X)
            {
                StylusPoint temp = start;
                start = end;
                end   = temp;
            }

            StylusPoint[] pts = getMidPoints(start, end);
            for (int i = 1; i < pts.Length; i++)
            {
                StylusPoint p1  = pts[i - 1];
                StylusPoint p2  = pts[i];
                int         num = (int)(MathTool.getInstance().distanceP2P(p1, p2));

                StylusPoint b    = new StylusPoint();
                StylusPoint temp = new StylusPoint(p1.X + (p2.X - p1.X) / 3, p1.Y + (p2.Y - p1.Y) / 3);

                double angle  = MathTool.getInstance().getAngleP2P(p1, p2);
                double angle1 = 90 + angle;
                double kk     = Math.Tan(angle1 / 180);
                b.X = (int)(temp.X - H / kk);
                b.Y = temp.Y + H;

                for (int k = 0; k < num; k++)
                {
                    double t = k * 1.0 / num;
                    double a, e, c;
                    a = (1 - t) * (1 - t);
                    e = 2 * t * (1 - t);
                    c = t * t;
                    int x1 = (int)(p1.X * a + b.X * e + p2.X * c);
                    int y1 = (int)(p1.Y * a + b.Y * e + p2.Y * c);
                    collection.Add(new StylusPoint(x1, y1));
                }
            }

            return(collection);
        }
Esempio n. 55
0
		public void Stroke_StylusPointCollection ()
		{
			StylusPointCollection spc = new StylusPointCollection ();
			spc.Add (new StylusPoint (1, 2));

			Stroke s = new Stroke (spc);
			Assert.AreEqual (1, s.StylusPoints.Count, "StylusPoints-1");

			spc.Add (new StylusPoint (3, 4));
			Assert.AreEqual (2, s.StylusPoints.Count, "StylusPoints-2");

			s.StylusPoints.Add (new StylusPoint (5, 6));
			Assert.AreEqual (3, s.StylusPoints.Count, "StylusPoints-3a");
			Assert.AreEqual (3, spc.Count, "StylusPoints-3b");

			Assert.Throws<ArgumentException> (delegate {
				s.HitTest (null);
			}, "HitTest-null");
			Assert.IsTrue (s.HitTest (s.StylusPoints), "HitTest-StylusPoints");
		}
Esempio n. 56
0
        public TouchPoint2(TouchInfo info, UIElement source)
        {
            this.Source = source;

            #if SILVERLIGHT
            Stroke = new Stroke();
            #else
            var stylusPoints = new StylusPointCollection(1);
            stylusPoints.Add(new StylusPoint(info.Position.X, info.Position.Y));
            Stroke = new Stroke(stylusPoints);
            #endif

            TouchDeviceId = info.TouchDeviceId;
            StartTime = DateTime.Now;

            #if SILVERLIGHT
            UpdateTouchStroke(info);
            #endif
            UpdateTouchInfo(info);
        }
Esempio n. 57
0
        /// <summary>Create a stroke from a StylusPointCollection</summary>
        /// <remarks>
        /// </remarks>
        /// <param name="stylusPoints">StylusPointCollection that makes up the stroke</param> 
        /// <param name="drawingAttributes">drawingAttributes</param>
        /// <param name="extendedProperties">extendedProperties</param> 
        internal Stroke(StylusPointCollection stylusPoints, DrawingAttributes drawingAttributes, ExtendedPropertyCollection extendedProperties) 
        {
            if (stylusPoints == null) 
            {
                throw new ArgumentNullException("stylusPoints");
            }
            if (stylusPoints.Count == 0) 
            {
                throw new ArgumentException(SR.Get(SRID.InvalidStylusPointCollectionZeroCount), "stylusPoints"); 
            } 
            if (drawingAttributes == null)
            { 
                throw new ArgumentNullException("drawingAttributes");
            }

            _drawingAttributes = drawingAttributes; 
            _stylusPoints = stylusPoints;
            _extendedProperties = extendedProperties; 
 
            Initialize();
        } 
        private StrokeCollection GetStrokeCollectionFromPoints(dynamic strokePoints)
        {
            var strokeCollection = new StrokeCollection();

            foreach (var stroke in strokePoints.Strokes)
            {
                var points = new StylusPointCollection();

                foreach (var point in stroke.Points)
                {
                    var x = (float)point.X;
                    var y = (float)point.Y;

                    points.Add(new StylusPoint(x, y));
                }

                strokeCollection.Add(new Stroke(points));
            }

            return strokeCollection;
        }
Esempio n. 59
0
        public static StrokeCollection ConvertToStrokeCollection(SerializableStrokeCollection strokeCollection)
        {
            StrokeCollection resultCollection = new StrokeCollection();
            foreach (var stroke in strokeCollection)
            {
                DrawingAttributes drawingAttr = new DrawingAttributes
                {
                    Color = stroke.DrawingAttributes.Color,
                    FitToCurve = stroke.DrawingAttributes.FitToCurve,
                    Height = stroke.DrawingAttributes.Height,
                    Width = stroke.DrawingAttributes.Width,
                    IgnorePressure = stroke.DrawingAttributes.IgnorePressure,
                    IsHighlighter = stroke.DrawingAttributes.IsHighlighter,
                    StylusTipTransform = stroke.DrawingAttributes.StylusTipTransform
                };
                switch (stroke.DrawingAttributes.StylusTip)
                {
                    case SerializableDrawingAttributes.StylusTips.Ellipse:
                        drawingAttr.StylusTip = StylusTip.Ellipse;
                        break;
                    case SerializableDrawingAttributes.StylusTips.Rectangle:
                        drawingAttr.StylusTip = StylusTip.Rectangle;
                        break;
                    default:
                        break;
                }

                StylusPointCollection spc = new StylusPointCollection();
                foreach (var stylusPoint in stroke.StylusPoints)
                {
                    StylusPoint sp = new StylusPoint { X = stylusPoint.X, Y = stylusPoint.Y, PressureFactor = stylusPoint.PressureFactor };
                    spc.Add(sp);
                }
                Stroke newStroke = new Stroke(spc);
                newStroke.DrawingAttributes = drawingAttr;
                resultCollection.Add(newStroke);
            }
            return resultCollection;
        }
Esempio n. 60
0
        /// <summary>
        /// StylusInputContinue
        /// </summary>
        /// <param name="stylusPoints">stylusPoints</param>
        /// <param name="userInitiated">true if the source eventArgs.UserInitiated flag was set to true</param>
        protected override void StylusInputContinue(StylusPointCollection stylusPoints, bool userInitiated)
        {
            _stylusPoints.Add(stylusPoints);

            _incrementalStrokeHitTester.AddPoints(stylusPoints);
        }