Ejemplo n.º 1
0
        public D2DSize MeasureText(string text, string fontName, float fontSize, D2DSize placeSize)
        {
            D2DSize outputSize = placeSize;

            D2D.MeasureText(this.Handle, text, fontName, fontSize, ref outputSize);
            return(outputSize);
        }
Ejemplo n.º 2
0
        public D2DBitmapGraphics CreateBitmapGraphics(D2DSize size)
        {
            HANDLE bitmapRenderTargetHandle = D2D.CreateBitmapRenderTarget(this.Handle, size);

            return(bitmapRenderTargetHandle == HANDLE.Zero ? null
                                : new D2DBitmapGraphics(bitmapRenderTargetHandle));
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public void DrawEllipse(D2DPoint origin, D2DSize radial, D2DColor color,
                                FLOAT weight = 1, D2DDashStyle dashStyle = D2DDashStyle.Solid)
        {
            var ellipse = new D2DEllipse(origin, radial);

            this.DrawEllipse(ellipse, color, weight, dashStyle);
        }
Ejemplo n.º 6
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);
Ejemplo n.º 7
0
 public void FillRectangle(D2DPoint origin, D2DSize size, D2DColor color)
 {
     this.FillRectangle(new D2DRect(origin, size), color);
 }
Ejemplo n.º 8
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);
 }
Ejemplo n.º 9
0
 public static extern void AddPathArc(HANDLE ctx, D2DPoint endPoint, D2DSize size, FLOAT sweepAngle,
                                      D2DArcSize arcSize = D2DArcSize.Small,
                                      D2DSweepDirection sweepDirection = D2DSweepDirection.Clockwise);
Ejemplo n.º 10
0
 public static extern void MeasureText([In] HANDLE ctx, [In] string text, [In] string fontName,
                                       [In] FLOAT fontSize, ref D2DSize size);
Ejemplo n.º 11
0
 public D2DEllipse(D2DPoint center, D2DSize radius)
     : this(center, radius.width, radius.height)
 {
 }
Ejemplo n.º 12
0
 public D2DRect(D2DPoint origin, D2DSize size)
     : this(origin.x - size.width * 0.5f, origin.y - size.height * 0.5f, size.width, size.height)
 {
 }
Ejemplo n.º 13
0
 public void AddArc(D2DPoint endPoint, D2DSize size, FLOAT sweepAngle,
                    D2D1_ARC_SIZE arcSize = D2D1_ARC_SIZE.D2D1_ARC_SIZE_SMALL,
                    D2D1_SWEEP_DIRECTION sweepDirection = D2D1_SWEEP_DIRECTION.D2D1_SWEEP_DIRECTION_CLOCKWISE)
 {
     D2D.AddPathArc(this.Handle, endPoint, size, sweepAngle, arcSize, sweepDirection);
 }
Ejemplo n.º 14
0
        public D2DGeometry CreateEllipseGeometry(D2DPoint origin, D2DSize size)
        {
            var ellipse = new D2DEllipse(origin, size);

            return(new D2DGeometry(this.Handle, D2D.CreateEllipseGeometry(this.Handle, ref ellipse)));
        }
Ejemplo n.º 15
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);
 }
Ejemplo n.º 16
0
 public static extern HANDLE CreateBitmapRenderTarget([In] HANDLE context, D2DSize size);
Ejemplo n.º 17
0
        // TODO: unnecessary API and it doesn't work very well, consider to remove
        //public void AddEllipse(D2DEllipse ellipse)
        //{
        //	D2D.AddPathEllipse(this.Handle, ref ellipse);
        //}

        public void AddArc(D2DPoint endPoint, D2DSize size, FLOAT sweepAngle,
                           D2DArcSize arcSize = D2DArcSize.Small,
                           D2DSweepDirection sweepDirection = D2DSweepDirection.Clockwise)
        {
            D2D.AddPathArc(this.Handle, endPoint, size, sweepAngle, arcSize, sweepDirection);
        }