コード例 #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);
        }
コード例 #2
0
ファイル: D2DLib.cs プロジェクト: patmosxx-v2/d2dlib
        public D2DBitmapGraphics CreateBitmapGraphics(D2DSize size)
        {
            HANDLE bitmapRenderTargetHandle = D2D.CreateBitmapRenderTarget(this.Handle, size);

            return(bitmapRenderTargetHandle == HANDLE.Zero ? null
                                : new D2DBitmapGraphics(bitmapRenderTargetHandle));
        }
コード例 #3
0
ファイル: D2DDevice.cs プロジェクト: yply/d2dlib
        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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #6
0
ファイル: D2DLib.cs プロジェクト: patmosxx-v2/d2dlib
 public static extern void AddPathArc(HANDLE ctx, D2DSize size, D2DPoint endPoint, FLOAT sweepAngle,
                                      D2D1_SWEEP_DIRECTION sweepDirection = D2D1_SWEEP_DIRECTION.D2D1_SWEEP_DIRECTION_CLOCKWISE);
コード例 #7
0
 public void FillRectangle(D2DPoint origin, D2DSize size, D2DColor color)
 {
     this.FillRectangle(new D2DRect(origin, size), color);
 }
コード例 #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);
 }
コード例 #9
0
ファイル: D2DLib.cs プロジェクト: jingwood/d2dlib
 public static extern void AddPathArc(HANDLE ctx, D2DPoint endPoint, D2DSize size, FLOAT sweepAngle,
                                      D2DArcSize arcSize = D2DArcSize.Small,
                                      D2DSweepDirection sweepDirection = D2DSweepDirection.Clockwise);
コード例 #10
0
ファイル: D2DLib.cs プロジェクト: hixio-mh/d2dlib
 public static extern void MeasureText([In] HANDLE ctx, [In] string text, [In] string fontName,
                                       [In] FLOAT fontSize, ref D2DSize size);
コード例 #11
0
 public D2DEllipse(D2DPoint center, D2DSize radius)
     : this(center, radius.width, radius.height)
 {
 }
コード例 #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)
 {
 }
コード例 #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);
 }
コード例 #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)));
        }
コード例 #15
0
ファイル: D2DLib.cs プロジェクト: patmosxx-v2/d2dlib
 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);
 }
コード例 #16
0
ファイル: D2DLib.cs プロジェクト: patmosxx-v2/d2dlib
 public static extern HANDLE CreateBitmapRenderTarget([In] HANDLE context, D2DSize size);
コード例 #17
0
ファイル: D2DPathGeometry.cs プロジェクト: jingwood/d2dlib
        // 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);
        }