示例#1
0
        public PointF TransformPoint(Point p)
        {
            s.DrawingPointF v =
                s.Matrix3x2.TransformPoint(
                    this.Control,
                    p.ToWpf()); // implicit conversion from Vector2 to DrawingPointF

            return(v.ToEto());
        }
示例#2
0
        public static s.DrawingPointF[] ToDx(this PointF[] points)
        {
            var p = new s.DrawingPointF[points.Length];

            for (var i = 0;
                 i < points.Length;
                 ++i)
            {
                p[i] = points[i].ToWpf();
            }

            return(p);
        }
示例#3
0
 public static Point ToEto(this s.DrawingPointF value)
 {
     return(new Point((int)value.X, (int)value.Y));
 }
        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;
            }
        }
示例#5
0
 public bool Contains(DrawingPointF point)
 {
     return((double)point.X >= (double)this.X && (double)point.X <= (double)this.X + (double)this.Width && ((double)point.Y >= (double)this.Y && (double)point.Y <= (double)this.Y + (double)this.Width));
 }
示例#6
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.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;
            }
        }
示例#7
0
 public bool Contains(DrawingPointF point)
 {
     return((double)point.X >= (double)this._left && (double)point.X <= (double)this._right && ((double)point.Y >= (double)this._top && (double)point.Y <= (double)this._bottom));
 }
示例#8
0
 public static DrawingPointF NextDPointF(this Random random, DrawingPointF min, DrawingPointF max)
 {
     return(new DrawingPointF(MathUtil.NextFloat(random, min.X, max.X), MathUtil.NextFloat(random, min.Y, max.Y)));
 }
示例#9
0
        public static s.DrawingPointF[] ToDx(this PointF[] points)
        {
            var p = new s.DrawingPointF[points.Length];

            for (var i = 0;
                i < points.Length;
                ++i)
                p[i] = points[i].ToWpf();

            return p;
        }