Exemple #1
0
 public static void DrawText(this IComObject <ID2D1RenderTarget> renderTarget,
                             string text,
                             IComObject <IDWriteTextFormat> format,
                             D2D_RECT_F rect,
                             IComObject <ID2D1Brush> brush,
                             D2D1_DRAW_TEXT_OPTIONS options      = D2D1_DRAW_TEXT_OPTIONS.D2D1_DRAW_TEXT_OPTIONS_NONE,
                             DWRITE_MEASURING_MODE measuringMode = DWRITE_MEASURING_MODE.DWRITE_MEASURING_MODE_NATURAL) => DrawText(renderTarget?.Object, text, format?.Object, rect, brush?.Object, options, measuringMode);
Exemple #2
0
        public static void DrawText(this ID2D1RenderTarget renderTarget,
                                    string text,
                                    IDWriteTextFormat format,
                                    D2D_RECT_F rect,
                                    ID2D1Brush brush,
                                    D2D1_DRAW_TEXT_OPTIONS options      = D2D1_DRAW_TEXT_OPTIONS.D2D1_DRAW_TEXT_OPTIONS_NONE,
                                    DWRITE_MEASURING_MODE measuringMode = DWRITE_MEASURING_MODE.DWRITE_MEASURING_MODE_NATURAL)
        {
            if (renderTarget == null)
            {
                throw new ArgumentNullException(nameof(renderTarget));
            }

            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            if (text == null)
            {
                return;
            }

            renderTarget.DrawTextW(text, (uint)text.Length, format, ref rect, brush, options, measuringMode);
        }
 public static void DrawText(this ComObject <ID2D1DeviceContext> device,
                             string text,
                             ComObject <IDWriteTextFormat> format,
                             D2D_RECT_F rect,
                             ComObject <ID2D1Brush> brush,
                             D2D1_DRAW_TEXT_OPTIONS options      = D2D1_DRAW_TEXT_OPTIONS.D2D1_DRAW_TEXT_OPTIONS_NONE,
                             DWRITE_MEASURING_MODE measuringMode = DWRITE_MEASURING_MODE.DWRITE_MEASURING_MODE_NATURAL) => DrawText(device?.Object, text, format?.Object, rect, brush?.Object, options, measuringMode);
Exemple #4
0
        public static void DrawText(this ID2D1DeviceContext context,
                                    string text,
                                    IDWriteTextFormat format,
                                    D2D_RECT_F rect,
                                    ID2D1Brush defaultFillBrush,
                                    D2D1_DRAW_TEXT_OPTIONS options      = D2D1_DRAW_TEXT_OPTIONS.D2D1_DRAW_TEXT_OPTIONS_NONE,
                                    DWRITE_MEASURING_MODE measuringMode = DWRITE_MEASURING_MODE.DWRITE_MEASURING_MODE_NATURAL)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            if (defaultFillBrush == null)
            {
                throw new ArgumentNullException(nameof(defaultFillBrush));
            }

            if (text == null)
            {
                return;
            }

            context.DrawTextW(text, (uint)text.Length, format, ref rect, defaultFillBrush, options, measuringMode);
        }
        public static void DrawText(this ID2D1DeviceContext device,
                                    string text,
                                    IDWriteTextFormat format,
                                    D2D_RECT_F rect,
                                    ID2D1Brush brush,
                                    D2D1_DRAW_TEXT_OPTIONS options      = D2D1_DRAW_TEXT_OPTIONS.D2D1_DRAW_TEXT_OPTIONS_NONE,
                                    DWRITE_MEASURING_MODE measuringMode = DWRITE_MEASURING_MODE.DWRITE_MEASURING_MODE_NATURAL)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            if (format == null)
            {
                throw new ArgumentNullException(nameof(format));
            }

            if (text == null)
            {
                return;
            }

#pragma warning disable CA2010 // Always consume the value returned by methods marked with PreserveSigAttribute
            device.DrawTextW(text, (uint)text.Length, format, ref rect, brush, options, measuringMode);
#pragma warning restore CA2010 // Always consume the value returned by methods marked with PreserveSigAttribute
        }
Exemple #6
0
        public static void PushAxisAlignedClip(this ID2D1RenderTarget renderTarget, D2D_RECT_F clipRect, D2D1_ANTIALIAS_MODE antialiasMode = D2D1_ANTIALIAS_MODE.D2D1_ANTIALIAS_MODE_PER_PRIMITIVE)
        {
            if (renderTarget == null)
            {
                throw new ArgumentNullException(nameof(renderTarget));
            }

            renderTarget.PushAxisAlignedClip(ref clipRect, antialiasMode);
        }
Exemple #7
0
        public static void FillRectangle(this ID2D1RenderTarget context, D2D_RECT_F rect, ID2D1Brush brush)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (brush == null)
            {
                throw new ArgumentNullException(nameof(brush));
            }

            context.FillRectangle(ref rect, brush);
        }
Exemple #8
0
        public static void DrawRectangle(this ID2D1RenderTarget context, D2D_RECT_F rect, ID2D1Brush brush, float strokeWidth, ID2D1StrokeStyle strokeStyle = null)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (brush == null)
            {
                throw new ArgumentNullException(nameof(brush));
            }

            context.DrawRectangle(ref rect, brush, strokeWidth, strokeStyle);
        }
Exemple #9
0
 public static void PushAxisAlignedClip(this IComObject <ID2D1RenderTarget> renderTarget, D2D_RECT_F clipRect, D2D1_ANTIALIAS_MODE antialiasMode = D2D1_ANTIALIAS_MODE.D2D1_ANTIALIAS_MODE_PER_PRIMITIVE) => PushAxisAlignedClip(renderTarget?.Object, clipRect, antialiasMode);
Exemple #10
0
 public static void FillRectangle(this IComObject <ID2D1RenderTarget> context, D2D_RECT_F rect, IComObject <ID2D1Brush> brush) => FillRectangle(context?.Object, rect, brush?.Object);
Exemple #11
0
 public static void DrawRectangle(this IComObject <ID2D1RenderTarget> context, D2D_RECT_F rect, IComObject <ID2D1Brush> brush, float strokeWidth, IComObject <ID2D1StrokeStyle> strokeStyle = null) => DrawRectangle(context?.Object, rect, brush?.Object, strokeWidth, strokeStyle?.Object);
Exemple #12
0
        public static IComObject <ID2D1RectangleGeometry> CreateRectangleGeometry(this ID2D1Factory factory, D2D_RECT_F rectangle)
        {
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            factory.CreateRectangleGeometry(ref rectangle, out var geometry).ThrowOnError();
            return(new ComObject <ID2D1RectangleGeometry>(geometry));
        }
Exemple #13
0
 public static IComObject <ID2D1RectangleGeometry> CreateRectangleGeometry(this IComObject <ID2D1Factory> factory, D2D_RECT_F rectangle) => CreateRectangleGeometry(factory?.Object, rectangle);