Exemple #1
0
        public void FillPolygon(DUIBrush brush, PointF[] points)
        {
            bool closed = true;

            if (points == null)
            {
                return;
            }
            if (points.Length < 3)
            {
                return;
            }
            brush.RenderTarget = this.target;
            using (SharpDX.Direct2D1.PathGeometry pathGeometry = new SharpDX.Direct2D1.PathGeometry(this.target.RenderTarget.Factory))
                using (SharpDX.Direct2D1.GeometrySink geometrySink = pathGeometry.Open())
                {
                    geometrySink.SetFillMode(SharpDX.Direct2D1.FillMode.Alternate);
                    geometrySink.BeginFigure(DxConvert.ToVector2(points[0]), SharpDX.Direct2D1.FigureBegin.Filled);
                    for (int i = 1; i < points.Length; i++)
                    {
                        geometrySink.AddLine(DxConvert.ToVector2(points[i]));
                    }
                    geometrySink.EndFigure(closed ? SharpDX.Direct2D1.FigureEnd.Closed : SharpDX.Direct2D1.FigureEnd.Open);
                    geometrySink.Close();
                    this.target.RenderTarget.FillGeometry(pathGeometry, brush);
                }
        }
Exemple #2
0
 public void DrawBezier(DUIPen pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
 {
     pen.RenderTarget = this.target;
     if (pen.IsDefaultStyleProperties)
     {
         using (SharpDX.Direct2D1.PathGeometry pathGeometry = new SharpDX.Direct2D1.PathGeometry(this.target.RenderTarget.Factory))
             using (SharpDX.Direct2D1.GeometrySink geometrySink = pathGeometry.Open())
             {
                 geometrySink.BeginFigure(DxConvert.ToVector2(x1, y1), SharpDX.Direct2D1.FigureBegin.Hollow);
                 geometrySink.AddBezier(new SharpDX.Direct2D1.BezierSegment()
                 {
                     Point1 = DxConvert.ToVector2(x2, y2), Point2 = DxConvert.ToVector2(x3, y3), Point3 = DxConvert.ToVector2(x4, y4)
                 });
                 geometrySink.EndFigure(SharpDX.Direct2D1.FigureEnd.Open);
                 geometrySink.Close();
                 this.target.RenderTarget.DrawGeometry(pathGeometry, pen, pen.Width);
             }
     }
     else
     {
         using (SharpDX.Direct2D1.PathGeometry pathGeometry = new SharpDX.Direct2D1.PathGeometry(this.target.RenderTarget.Factory))
             using (SharpDX.Direct2D1.GeometrySink geometrySink = pathGeometry.Open())
             {
                 geometrySink.BeginFigure(DxConvert.ToVector2(x1, y1), SharpDX.Direct2D1.FigureBegin.Hollow);
                 geometrySink.AddBezier(new SharpDX.Direct2D1.BezierSegment()
                 {
                     Point1 = DxConvert.ToVector2(x2, y2), Point2 = DxConvert.ToVector2(x3, y3), Point3 = DxConvert.ToVector2(x4, y4)
                 });
                 geometrySink.EndFigure(SharpDX.Direct2D1.FigureEnd.Open);
                 geometrySink.Close();
                 this.target.RenderTarget.DrawGeometry(pathGeometry, pen, pen.Width, pen);
             }
     }
 }
Exemple #3
0
        public void DrawPolygon(DUIPen pen, PointF[] points)
        {
            bool closed = true;

            if (points == null)
            {
                return;
            }
            if (points.Length < (closed ? 3 : 2))
            {
                return;
            }
            pen.RenderTarget = this.target;
            if (pen.IsDefaultStyleProperties)
            {
                using (SharpDX.Direct2D1.PathGeometry pathGeometry = new SharpDX.Direct2D1.PathGeometry(this.target.RenderTarget.Factory))
                    using (SharpDX.Direct2D1.GeometrySink geometrySink = pathGeometry.Open())
                    {
                        geometrySink.BeginFigure(DxConvert.ToVector2(points[0]), SharpDX.Direct2D1.FigureBegin.Filled);
                        for (int i = 1; i < points.Length; i++)
                        {
                            geometrySink.AddLine(DxConvert.ToVector2(points[i]));
                        }
                        geometrySink.EndFigure(closed ? SharpDX.Direct2D1.FigureEnd.Closed : SharpDX.Direct2D1.FigureEnd.Open);
                        geometrySink.Close();
                        this.target.RenderTarget.DrawGeometry(pathGeometry, pen, pen.Width);
                    }
            }
            else
            {
                using (SharpDX.Direct2D1.PathGeometry pathGeometry = new SharpDX.Direct2D1.PathGeometry(this.target.RenderTarget.Factory))
                    using (SharpDX.Direct2D1.GeometrySink geometrySink = pathGeometry.Open())
                    {
                        geometrySink.BeginFigure(DxConvert.ToVector2(points[0]), SharpDX.Direct2D1.FigureBegin.Filled);
                        for (int i = 1; i < points.Length; i++)
                        {
                            geometrySink.AddLine(DxConvert.ToVector2(points[i]));
                        }
                        geometrySink.EndFigure(closed ? SharpDX.Direct2D1.FigureEnd.Closed : SharpDX.Direct2D1.FigureEnd.Open);
                        geometrySink.Close();
                        this.target.RenderTarget.DrawGeometry(pathGeometry, pen, pen.Width, pen);
                    }
            }
        }
Exemple #4
0
 public void DrawImage(DUIImage image, PointF[] polygon, GraphicsUnit srcUnit, float opacity)
 {
     image.RenderTarget = this.target;
     using (DirectUI.Common.DUIBitmapBrush dbs = new DirectUI.Common.DUIBitmapBrush(image, DUIExtendMode.Clamp, opacity))
         using (SharpDX.Direct2D1.PathGeometry pathGeometry = new SharpDX.Direct2D1.PathGeometry(this.target.RenderTarget.Factory))
             using (SharpDX.Direct2D1.GeometrySink gs1 = pathGeometry.Open())
             {
                 dbs.RenderTarget = this.target;
                 gs1.SetFillMode(SharpDX.Direct2D1.FillMode.Alternate);
                 gs1.BeginFigure(DxConvert.ToVector2(polygon[0]), SharpDX.Direct2D1.FigureBegin.Filled);
                 for (int i = 1; i < polygon.Length; i++)
                 {
                     gs1.AddLine(DxConvert.ToVector2(polygon[i]));
                 }
                 gs1.EndFigure(SharpDX.Direct2D1.FigureEnd.Closed);
                 gs1.Close();
                 this.target.RenderTarget.FillGeometry(pathGeometry, dbs);
             }
 }
Exemple #5
0
        public void DrawImage(DUIImage image, PointF[] destTriangle, PointF[] srcTriangle, GraphicsUnit srcUnit, float opacity)
        {
            PointF t1 = destTriangle[0];
            PointF t2 = destTriangle[1];
            PointF t3 = destTriangle[2];

            image.RenderTarget = this.target;
            using (DirectUI.Common.DUIBitmapBrush dbs = new DirectUI.Common.DUIBitmapBrush(image, DUIExtendMode.Clamp, opacity))
                using (SharpDX.Direct2D1.PathGeometry pathGeometry = new SharpDX.Direct2D1.PathGeometry(this.target.RenderTarget.Factory))
                    using (SharpDX.Direct2D1.GeometrySink gs1 = pathGeometry.Open())
                    {
                        dbs.RenderTarget = this.target;
                        gs1.SetFillMode(SharpDX.Direct2D1.FillMode.Alternate);
                        gs1.BeginFigure(DxConvert.ToVector2(t1), SharpDX.Direct2D1.FigureBegin.Filled);
                        gs1.AddLine(DxConvert.ToVector2(t2));
                        gs1.AddLine(DxConvert.ToVector2(t3));
                        gs1.EndFigure(SharpDX.Direct2D1.FigureEnd.Closed);
                        gs1.Close();
                        dbs.Transform = MatrixTools.ThreePointsAffine(srcTriangle, destTriangle);
                        this.target.RenderTarget.FillGeometry(pathGeometry, dbs);
                    }
        }