Exemplo n.º 1
0
        public D2DGeometry CreatePieGeometry(D2DPoint origin, D2DSize size, float startAngle, float endAngle)
        {
            var path = this.CreatePathGeometry();

            var halfSize = new D2DSize(size.width * 0.5f, size.height * 0.5f);

            var sangle    = startAngle * Math.PI / 180f;
            var eangle    = endAngle * Math.PI / 180f;
            var angleDiff = endAngle - startAngle;

            var startPoint = new D2DPoint((float)(origin.x + halfSize.width * Math.Cos(sangle)),
                                          (float)(origin.y + halfSize.height * Math.Sin(sangle)));

            var endPoint = new D2DPoint((float)(origin.x + halfSize.width * Math.Cos(eangle)),
                                        (float)(origin.y + halfSize.height * Math.Sin(eangle)));

            path.AddLines(new D2DPoint[] { origin, startPoint });

            path.AddArc(endPoint, halfSize, angleDiff,
                        angleDiff > 180 ? D2D1_ARC_SIZE.D2D1_ARC_SIZE_LARGE : D2D1_ARC_SIZE.D2D1_ARC_SIZE_SMALL,
                        D2D1_SWEEP_DIRECTION.D2D1_SWEEP_DIRECTION_CLOCKWISE);

            path.ClosePath();

            return(path);
        }
Exemplo n.º 2
0
        public D2DGeometry CreatePieGeometry(D2DPoint origin, D2DSize size, float startAngle, float endAngle)
        {
            var path = this.CreatePathGeometry();

            var halfSize = new D2DSize(size.width * 0.5f, size.height * 0.5f);

            var sangle    = startAngle * Math.PI / 180f;
            var eangle    = endAngle * Math.PI / 180f;
            var angleDiff = endAngle - startAngle;

            var startPoint = new D2DPoint((float)(origin.x + halfSize.width * Math.Cos(sangle)),
                                          (float)(origin.y + halfSize.height * Math.Sin(sangle)));

            var endPoint = new D2DPoint((float)(origin.x + halfSize.width * Math.Cos(eangle)),
                                        (float)(origin.y + halfSize.height * Math.Sin(eangle)));

            path.AddLines(new D2DPoint[] { origin, startPoint });

            path.AddArc(endPoint, halfSize, angleDiff,
                        angleDiff > 180 ? D2DArcSize.Large : D2DArcSize.Small,
                        D2DSweepDirection.Clockwise);

            path.ClosePath();

            return(path);
        }
Exemplo n.º 3
0
        public void DrawEllipse(D2DPoint origin, FLOAT radialX, FLOAT radialY, D2DColor color,
                                FLOAT weight = 1, D2DDashStyle dashStyle = D2DDashStyle.Solid)
        {
            var ellipse = new D2DEllipse(origin, radialX, radialY);

            this.DrawEllipse(ellipse, color, weight, dashStyle);
        }
Exemplo n.º 4
0
        public D2DLinearGradientBrush CreateLinearGradientBrush(D2DPoint startPoint, D2DPoint endPoint,
                                                                D2DGradientStop[] gradientStops)
        {
            HANDLE handle = D2D.CreateLinearGradientBrush(this.Handle, startPoint, endPoint, gradientStops, (uint)gradientStops.Length);

            return(new D2DLinearGradientBrush(handle, gradientStops));
        }
Exemplo n.º 5
0
        public D2DRadialGradientBrush CreateRadialGradientBrush(D2DPoint origin, D2DPoint offset,
                                                                FLOAT radiusX, FLOAT radiusY,
                                                                D2DGradientStop[] gradientStops)
        {
            HANDLE handle = D2D.CreateRadialGradientBrush(this.Handle, origin, offset, radiusX, radiusY,
                                                          gradientStops, (uint)gradientStops.Length);

            return(new D2DRadialGradientBrush(handle, gradientStops));
        }
Exemplo n.º 6
0
        public void FillEllipse(D2DPoint p, FLOAT w, FLOAT h, D2DColor color)
        {
            D2DEllipse ellipse = new D2DEllipse(p, w / 2, h / 2);

            ellipse.origin.x += ellipse.radiusX;
            ellipse.origin.y += ellipse.radiusY;

            this.FillEllipse(ellipse, color);
        }
Exemplo n.º 7
0
 public static extern void SkewTransform([In] HANDLE ctx, [In] FLOAT angleX, [In] FLOAT angleY, [Optional] D2DPoint center);
Exemplo n.º 8
0
 public D2DBezierSegment(FLOAT x1, FLOAT y1, FLOAT x2, FLOAT y2, FLOAT x3, FLOAT y3)
 {
     this.point1 = new D2DPoint(x1, y1);
     this.point2 = new D2DPoint(x2, y2);
     this.point3 = new D2DPoint(x3, y3);
 }
Exemplo n.º 9
0
 public bool FillContainsPoint(D2DPoint point)
 {
     return(D2D.PathFillContainsPoint(this.Handle, point));
 }
Exemplo n.º 10
0
 public static extern HANDLE CreateRadialGradientBrush(HANDLE ctx, D2DPoint origin, D2DPoint offset,
                                                       FLOAT radiusX, FLOAT radiusY, D2DGradientStop[] gradientStops,
                                                       UINT gradientStopCount);
Exemplo n.º 11
0
 public static extern bool PathStrokeContainsPoint(HANDLE pathCtx, D2DPoint point, FLOAT strokeWidth = 1,
                                                   D2DDashStyle dashStyle = D2DDashStyle.Solid);
Exemplo n.º 12
0
 public static extern void AddPathArc(HANDLE ctx, D2DSize size, D2DPoint endPoint, FLOAT sweepAngle,
                                      D2D1_SWEEP_DIRECTION sweepDirection = D2D1_SWEEP_DIRECTION.D2D1_SWEEP_DIRECTION_CLOCKWISE);
Exemplo n.º 13
0
 public void RotateTransform(FLOAT angle, D2DPoint center)
 {
     D2D.RotateTransform(this.Handle, angle, center);
 }
Exemplo n.º 14
0
 public void FillEllipse(D2DPoint p, FLOAT radial, D2DColor color)
 {
     this.FillEllipse(p, radial, radial, color);
 }
Exemplo n.º 15
0
 public void DrawLine(D2DPoint start, D2DPoint end, D2DColor color,
                      FLOAT weight = 1, D2DDashStyle dashStyle = D2DDashStyle.Solid)
 {
     D2D.DrawLine(this.Handle, start, end, color, weight, dashStyle);
 }
Exemplo n.º 16
0
 public static extern void SetPathStartPoint(HANDLE ctx, D2DPoint startPoint);
Exemplo n.º 17
0
 public void DrawLine(D2DPoint start, D2DPoint end, D2DColor color,
                      FLOAT weight         = 1, D2DDashStyle dashStyle = D2DDashStyle.Solid,
                      D2DCapStyle startCap = D2DCapStyle.Flat, D2DCapStyle endCap = D2DCapStyle.Flat)
 {
     D2D.DrawLine(this.Handle, start, end, color, weight, dashStyle, startCap, endCap);
 }
Exemplo n.º 18
0
 public static extern void SetTransform([In] HANDLE context, [In] FLOAT angle, [In] D2DPoint center);
Exemplo n.º 19
0
 public static extern void DrawLine(HANDLE context, D2DPoint start, D2DPoint end, D2DColor color,
                                    FLOAT weight = 1, D2DDashStyle dashStyle = D2DDashStyle.Solid);
Exemplo n.º 20
0
 public void ScaleTransform(FLOAT sx, FLOAT sy, [Optional] D2DPoint center)
 {
     D2D.ScaleTransform(this.Handle, sx, sy, center);
 }
Exemplo n.º 21
0
 public static extern bool PathFillContainsPoint(HANDLE pathCtx, D2DPoint point);
Exemplo n.º 22
0
 public void SkewTransform(FLOAT angleX, FLOAT angleY, [Optional] D2DPoint center)
 {
     D2D.SkewTransform(this.Handle, angleX, angleY, center);
 }
Exemplo n.º 23
0
 public static extern HANDLE CreateLinearGradientBrush(HANDLE ctx, D2DPoint startPoint, D2DPoint endPoint,
                                                       D2DGradientStop[] gradientStops, UINT gradientStopCount);
Exemplo n.º 24
0
 public void DrawRectangle(D2DPoint origin, D2DSize size, D2DColor color, FLOAT strokeWidth = 1,
                           D2DDashStyle dashStyle = D2DDashStyle.Solid)
 {
     this.DrawRectangle(new D2DRect(origin, size), color, strokeWidth, dashStyle);
 }
Exemplo n.º 25
0
 public void FillRectangle(D2DPoint origin, D2DSize size, D2DColor color)
 {
     this.FillRectangle(new D2DRect(origin, size), color);
 }
Exemplo n.º 26
0
 public D2DEllipse(D2DPoint center, D2DSize radius)
     : this(center, radius.width, radius.height)
 {
 }
Exemplo n.º 27
0
 public void AddArc(D2DSize size, D2DPoint endPoint, FLOAT sweepAngle,
                    D2D1_SWEEP_DIRECTION sweepDirection = D2D1_SWEEP_DIRECTION.D2D1_SWEEP_DIRECTION_CLOCKWISE)
 {
     D2D.AddPathArc(this.Handle, size, endPoint, sweepAngle);
 }
Exemplo n.º 28
0
 public static extern void ScaleTransform([In] HANDLE context, [In] FLOAT sx, [In] FLOAT sy, [Optional] D2DPoint center);
Exemplo n.º 29
0
 public bool StrokeContainsPoint(D2DPoint point, FLOAT width = 1, D2DDashStyle dashStyle = D2DDashStyle.Solid)
 {
     return(D2D.PathStrokeContainsPoint(this.Handle, point, width, dashStyle));
 }
Exemplo n.º 30
0
 public D2DBezierSegment(D2DPoint point1, D2DPoint point2, D2DPoint point3)
 {
     this.point1 = point1;
     this.point2 = point2;
     this.point3 = point3;
 }