///<summary>
        /// Adds a <see cref="PathFigure"/> representing a polygon ring
        /// having the given coordinate sequence to the supplied <see cref="StreamGeometryContext"/>
        ///</summary>
        ///<param name="sgc">The stream geometry context.</param>
        ///<param name="coordinates">A coordinate sequence</param>
        ///<param name="filled">Starting paramter for </param>
        ///<returns>The path for the coordinate sequence</returns>
        private static void AddRing(StreamGeometryContext sgc, Coordinate[] coordinates, bool filled)
        {
            if (coordinates.Length <= 0)
                return;

            sgc.BeginFigure(ToPoint(coordinates[0]), filled, true);
            if (coordinates.Length > 0)
                sgc.PolyLineTo(ToPoint(coordinates, 1), true, true);
        }
Exemplo n.º 2
0
 /// <summary>
 /// SerializeData - Serialize the contents of this Segment to the provided context.
 /// </summary>
 internal override void SerializeData(StreamGeometryContext ctx)
 {
     ctx.PolyLineTo(Points, IsStroked, IsSmoothJoin);
 }                                    
Exemplo n.º 3
0
        /// <summary>
        /// Private helper to render a path figure to the SGC
        /// </summary>
        private static void AddArcToFigureToStreamGeometryContext(StreamGeometryContext context, List<Point> abPoints, List<Point> dcPoints, List<Point> polyLinePoints)
        {
            Debug.Assert(context != null);
            Debug.Assert(abPoints != null && dcPoints != null);
            Debug.Assert(polyLinePoints != null);
            //Debug.Assert(abPoints.Count > 0 && dcPoints.Count > 0);
            if (abPoints.Count == 0 || dcPoints.Count == 0)
            {
                return;
            }

            context.BeginFigure(abPoints[0], //start point
                                        true,   //isFilled
                                        true);  //IsClosed

            for (int j = 0; j < 2; j++)
            {
                List<Point> points = j == 0 ? abPoints : dcPoints;
                int startIndex = j == 0 ? 1 : 0;
                for (int i = startIndex; i < points.Count; )
                {
                    Point next = points[i];
                    if (next == StrokeRenderer.ArcToMarker)
                    {
                        if (polyLinePoints.Count > 0)
                        {
                            //polyline first
                            context.PolyLineTo(  polyLinePoints,
                                                 true,      //isStroked
                                                 true);     //isSmoothJoin
                            polyLinePoints.Clear();
                        }
                        //we're arcing, pull out height, width and the arc to point
                        Debug.Assert(i + 2 < points.Count);
                        if (i + 2 < points.Count)
                        {
                            Point sizePoint = points[i + 1];
                            Size ellipseSize = new Size(sizePoint.X / 2/*width*/, sizePoint.Y / 2/*height*/);
                            Point arcToPoint = points[i + 2];

                            bool isLargeArc = false; //>= 180

                            context.ArcTo(  arcToPoint,
                                            ellipseSize,
                                            0d,             //rotation
                                            isLargeArc,     //isLargeArc
                                            SweepDirection.Clockwise,
                                            true,           //isStroked
                                            true);          //isSmoothJoin
                        }
                        i += 3; //advance past this arcTo block
                    }
                    else
                    {
                        //walk forward until we find an arc marker or the end
                        polyLinePoints.Add(next);
                        i++;
                    }
                }
                if (polyLinePoints.Count > 0)
                {
                    //polyline
                    context.PolyLineTo(polyLinePoints,
                                         true,      //isStroked
                                         true);     //isSmoothJoin
                    polyLinePoints.Clear();
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Private helper to render a path figure to the SGC
        /// </summary>
        private static void AddPolylineFigureToStreamGeometryContext(StreamGeometryContext context, List<Point> abPoints, List<Point> dcPoints)
        {
            Debug.Assert(context != null);
            Debug.Assert(abPoints != null && dcPoints != null);
            Debug.Assert(abPoints.Count > 0 && dcPoints.Count > 0);

            context.BeginFigure(abPoints[0], //start point
                                        true,   //isFilled
                                        true);  //IsClosed

            context.PolyLineTo(abPoints,
                                 true,      //isStroked
                                 true);     //isSmoothJoin

            context.PolyLineTo(dcPoints,
                                 true,      //isStroked
                                 true);     //isSmoothJoin

        }
Exemplo n.º 5
0
        /// <summary>
        /// Private helper to render a path figure to the SGC
        /// </summary>
        private static void AddFigureToStreamGeometryContext(StreamGeometryContext context, List<Point> points, bool isBezierFigure)
        {
            Debug.Assert(context != null);
            Debug.Assert(points != null);
            Debug.Assert(points.Count > 0);

            context.BeginFigure(points[points.Count - 1], //start point
                                        true,   //isFilled
                                        true);  //IsClosed

            if (isBezierFigure)
            {
                context.PolyBezierTo(points,
                                     true,      //isStroked
                                     true);     //isSmoothJoin
            }
            else
            {
                context.PolyLineTo(points,
                                     true,      //isStroked
                                     true);     //isSmoothJoin
            }
        }
        public static void DrawFigure(StreamGeometryContext ctx, PathFigure figure)
        {
            ctx.BeginFigure(figure.StartPoint, figure.IsFilled, figure.IsClosed);
            foreach (var segment in figure.Segments)
            {
                var lineSegment = segment as WpfLineSegment;
                if (lineSegment != null) { ctx.LineTo(lineSegment.Point, lineSegment.IsStroked, lineSegment.IsSmoothJoin); continue; }

                var bezierSegment = segment as BezierSegment;
                if (bezierSegment != null) { ctx.BezierTo(bezierSegment.Point1, bezierSegment.Point2, bezierSegment.Point3, bezierSegment.IsStroked, bezierSegment.IsSmoothJoin); continue; }

                var quadraticSegment = segment as QuadraticBezierSegment;
                if (quadraticSegment != null) { ctx.QuadraticBezierTo(quadraticSegment.Point1, quadraticSegment.Point2, quadraticSegment.IsStroked, quadraticSegment.IsSmoothJoin); continue; }

                var polyLineSegment = segment as PolyLineSegment;
                if (polyLineSegment != null) { ctx.PolyLineTo(polyLineSegment.Points, polyLineSegment.IsStroked, polyLineSegment.IsSmoothJoin); continue; }

                var polyBezierSegment = segment as PolyBezierSegment;
                if (polyBezierSegment != null) { ctx.PolyBezierTo(polyBezierSegment.Points, polyBezierSegment.IsStroked, polyBezierSegment.IsSmoothJoin); continue; }

                var polyQuadraticSegment = segment as PolyQuadraticBezierSegment;
                if (polyQuadraticSegment != null) { ctx.PolyQuadraticBezierTo(polyQuadraticSegment.Points, polyQuadraticSegment.IsStroked, polyQuadraticSegment.IsSmoothJoin); continue; }

                var arcSegment = segment as ArcSegment;
                if (arcSegment != null) { ctx.ArcTo(arcSegment.Point, arcSegment.Size, arcSegment.RotationAngle, arcSegment.IsLargeArc, arcSegment.SweepDirection, arcSegment.IsStroked, arcSegment.IsSmoothJoin); continue; }
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// SerializeData - Serialize the contents of this Segment to the provided context.
 /// </summary>
 internal override void SerializeData(StreamGeometryContext ctx)
 {
     ctx.PolyLineTo(Points, IsStroked, IsSmoothJoin);
 }
Exemplo n.º 8
0
        void DrawArrow(StreamGeometryContext gc, Point from, Point to2, double Wings, double offset)
        {
            Point to = new Point(from.X * (1.0 - offset) + to2.X * offset, from.Y * (1.0 - offset) + to2.Y * offset);

            double dx = to2.X - from.X;
            double dy = to2.Y - from.Y;

            double len = Math.Sqrt(dx * dx + dy * dy);
            if (len == 0)
                return;

            dx = (dx / len) * (Wings);
            dy = (dy / len) * (Wings);

            Point A = new Point(to.X - dx, to.Y - dy);

            var pts0 = new Point(to.X, to.Y);
            dx /= 2;
            dy /= 2;
            var pts1 = new Point(A.X - dy, A.Y + dx);
            var pts2 = new Point(A.X + dx / 2, A.Y + dy / 2);
            var pts3 = new Point(A.X + dy, A.Y - dx);

            gc.BeginFigure(pts0, true, true);
            gc.PolyLineTo(new Point[] { pts1, pts2, pts3 }, true, true);
        }
Exemplo n.º 9
0
 private void DrawCustomShape(StreamGeometryContext context)
 {
     context.BeginFigure(this.DiagramPoints[0], true, false);
             context.PolyLineTo(this.DiagramPoints, true, true);
 }
Exemplo n.º 10
0
        private void InternalDrawArrowGeometry(StreamGeometryContext context)
        {
            Point pt1 = new Point(X1, this.Y1);
            Point pt2 = new Point(X2, this.Y2);

            var lastPt = pt1;
            context.BeginFigure(pt1, false, false);
            if (Points != null)
            {
                foreach (var point in Points)
                {
                    context.LineTo(point, true, true);
                }
                //The Previous Point (before the Endpoint) should be used for Angle Caluculation!
                if (Points.Count > 1)
                    lastPt = Points[Points.Count - 2];
            }
            context.LineTo(pt2, true, true);

            double theta = Math.Atan2(lastPt.Y - Y2, lastPt.X - X2);
            double sint = Math.Sin(theta);
            double cost = Math.Cos(theta);

            Point pt3 = new Point(
                X2 + (HeadWidth * cost - HeadHeight * sint),
                Y2 + (HeadWidth * sint + HeadHeight * cost));

            Point pt4 = new Point(
                X2 + (HeadWidth * cost + HeadHeight * sint),
                Y2 - (HeadHeight * cost - HeadWidth * sint));

            context.BeginFigure(pt2, true, false);
            context.PolyLineTo(new[] {pt3, pt4, pt2}, true, true);
        }