Esempio n. 1
0
        public static void AddPathFigureSegment(
            this D2D.GeometrySink sink, Jupiter.Media.PathSegment segment)
        {
            var bezierSegment = segment as BezierSegment;

            if (bezierSegment != null)
            {
                sink.AddBezier(
                    new D2D.BezierSegment
                {
                    Point1 = bezierSegment.Point1.ToSharpDX(),
                    Point2 = bezierSegment.Point2.ToSharpDX(),
                    Point3 = bezierSegment.Point3.ToSharpDX()
                });
                return;
            }

            var lineSegment = segment as LineSegment;

            if (lineSegment != null)
            {
                sink.AddLine(
                    lineSegment.Point.ToSharpDX());
                return;
            }

            var polyBezierSegment = segment as PolyBezierSegment;

            if (polyBezierSegment != null)
            {
                var beziers = new D2D.BezierSegment[polyBezierSegment.Points.Count / 3];

                for (int i = 0; i < beziers.Length; i++)
                {
                    beziers[i].Point1 = polyBezierSegment.Points[i * 3].ToSharpDX();
                    beziers[i].Point2 = polyBezierSegment.Points[i * 3 + 1].ToSharpDX();
                    beziers[i].Point3 = polyBezierSegment.Points[i * 3 + 2].ToSharpDX();
                }

                sink.AddBeziers(beziers);
                return;
            }

            var polyLineSegment = segment as PolyLineSegment;

            if (polyLineSegment != null)
            {
                var lines = new SharpDX.Vector2[polyLineSegment.Points.Count];

                for (int i = 0; i < lines.Length; i++)
                {
                    lines[i] = polyLineSegment.Points[i].ToSharpDX();
                }

                sink.AddLines(lines);
                return;
            }

            var quadraticBezierSegment = segment as QuadraticBezierSegment;

            if (quadraticBezierSegment != null)
            {
                sink.AddQuadraticBezier(
                    new D2D.QuadraticBezierSegment
                {
                    Point1 = quadraticBezierSegment.Point1.ToSharpDX(),
                    Point2 = quadraticBezierSegment.Point2.ToSharpDX()
                });
                return;
            }

            var polyQuadraticBezierSegment = segment as PolyQuadraticBezierSegment;

            if (polyQuadraticBezierSegment != null)
            {
                var quadraticBeziers = new D2D.QuadraticBezierSegment[polyBezierSegment.Points.Count / 2];

                for (int i = 0; i < quadraticBeziers.Length; i++)
                {
                    quadraticBeziers[i].Point1 = polyBezierSegment.Points[i * 2].ToSharpDX();
                    quadraticBeziers[i].Point2 = polyBezierSegment.Points[i * 2 + 1].ToSharpDX();
                }

                sink.AddQuadraticBeziers(quadraticBeziers);
                return;
            }

            var arcSegment = segment as ArcSegment;

            if (arcSegment != null)
            {
                sink.AddArc(
                    new D2D.ArcSegment
                {
                    Point          = arcSegment.Point.ToSharpDX(),
                    Size           = arcSegment.Size.ToSharpDX(),
                    RotationAngle  = (float)arcSegment.RotationAngle,
                    SweepDirection = arcSegment.SweepDirection.ToSharpDX(),
                    ArcSize        = arcSegment.IsLargeArc ? D2D.ArcSize.Large : D2D.ArcSize.Small
                });
                return;
            }
        }
        public static void AddPathFigureSegment(
            this D2D.GeometrySink sink, Jupiter.Media.PathSegment segment)
        {
            var bezierSegment = segment as BezierSegment;

            if (bezierSegment != null)
            {
                sink.AddBezier(
                    new D2D.BezierSegment
                    {
                        Point1 = bezierSegment.Point1.ToSharpDX(),
                        Point2 = bezierSegment.Point2.ToSharpDX(),
                        Point3 = bezierSegment.Point3.ToSharpDX()
                    });
                return;
            }

            var lineSegment = segment as LineSegment;

            if (lineSegment != null)
            {
                sink.AddLine(
                    lineSegment.Point.ToSharpDX());
                return;
            }

            var polyBezierSegment = segment as PolyBezierSegment;

            if (polyBezierSegment != null)
            {
                var beziers = new D2D.BezierSegment[polyBezierSegment.Points.Count / 3];

                for (int i = 0; i < beziers.Length; i++)
                {
                    beziers[i].Point1 = polyBezierSegment.Points[i * 3].ToSharpDX();
                    beziers[i].Point2 = polyBezierSegment.Points[i * 3 + 1].ToSharpDX();
                    beziers[i].Point3 = polyBezierSegment.Points[i * 3 + 2].ToSharpDX();
                }

                sink.AddBeziers(beziers);
                return;
            }

            var polyLineSegment = segment as PolyLineSegment;

            if (polyLineSegment != null)
            {
                var lines = new SharpDX.DrawingPointF[polyLineSegment.Points.Count];

                for (int i = 0; i < lines.Length; i++)
                {
                    lines[i] = polyLineSegment.Points[i].ToSharpDX();
                }

                sink.AddLines(lines);
                return;
            }

            var quadraticBezierSegment = segment as QuadraticBezierSegment;

            if (quadraticBezierSegment != null)
            {
                sink.AddQuadraticBezier(
                    new D2D.QuadraticBezierSegment
                    {
                        Point1 = quadraticBezierSegment.Point1.ToSharpDX(),
                        Point2 = quadraticBezierSegment.Point2.ToSharpDX()
                    });
                return;
            }

            var polyQuadraticBezierSegment = segment as PolyQuadraticBezierSegment;

            if (polyQuadraticBezierSegment != null)
            {
                var quadraticBeziers = new D2D.QuadraticBezierSegment[polyBezierSegment.Points.Count / 2];

                for (int i = 0; i < quadraticBeziers.Length; i++)
                {
                    quadraticBeziers[i].Point1 = polyBezierSegment.Points[i * 2].ToSharpDX();
                    quadraticBeziers[i].Point2 = polyBezierSegment.Points[i * 2 + 1].ToSharpDX();
                }

                sink.AddQuadraticBeziers(quadraticBeziers);
                return;
            }

            var arcSegment = segment as ArcSegment;

            if (arcSegment != null)
            {
                sink.AddArc(
                    new D2D.ArcSegment
                    {
                        Point = arcSegment.Point.ToSharpDX(),
                        Size = arcSegment.Size.ToSharpDX(),
                        RotationAngle = (float)arcSegment.RotationAngle,
                        SweepDirection = arcSegment.SweepDirection.ToSharpDX(),
                        ArcSize = arcSegment.IsLargeArc ? D2D.ArcSize.Large : D2D.ArcSize.Small
                    });
                return;
            }
        }