Class GDIPlusExtensions
Conversions between the backend-neutral drawing tools (RenderPen, RenderFont,
RenderStringFormat) and the System.Drawing (GDI+) objects. In ATAS X builds the pen and font
conversions use the cross-platform UniversalPen and UniversalFont types instead of Pen and Font.
public static class GDIPlusExtensions
- Inheritance
-
objectGDIPlusExtensions
Methods
ToBrush(Color)
Returns a GDI+ solid brush of color. For the known colors Color.White and Color.Black
it returns the shared system brushes, which must not be disposed; for other colors it creates a new brush that the caller owns.
public static SolidBrush ToBrush(this Color color)
Parameters
colorColorBrush color.
Returns
- SolidBrush
The brush.
ToGDIPlus(RenderFont?, double)
Creates a GDI+ font with the family, style and unit of font and its size multiplied by dpiY.
The caller owns and disposes the result.
Added in ATAS 8.0.15.
public static Font? ToGDIPlus(this RenderFont? font, double dpiY = 1)
Parameters
fontRenderFontFont to convert, can be null.
dpiYdoubleVertical DPI scale applied to the size, 1.0 for 96 DPI.
Returns
ToGDIPlus(RenderStringFormat?)
Creates a GDI+ string format with the alignment, line alignment, format flags and trimming of stringFormat.
The caller owns and disposes the result.
Added in ATAS 8.0.15.
public static StringFormat? ToGDIPlus(this RenderStringFormat? stringFormat)
Parameters
stringFormatRenderStringFormatFormat to convert, can be null.
Returns
ToPen(RenderPen, float)
Creates a GDI+ pen from renderPen. Width and arrow cap sizes are multiplied by scale;
the line join is MiterClipped. The caller owns and disposes the result.
Added in ATAS 8.0.15.
public static Pen ToPen(this RenderPen renderPen, float scale = 1)
Parameters
renderPenRenderPenPen to convert.
scalefloatScale factor for the width and cap sizes.
Returns
- Pen
The new pen.
Exceptions
- ArgumentNullException
renderPenis null.- ArgumentException
The dash pattern of
renderPenis rejected by GDI+; the error is logged before rethrowing.
ToRender(Font?, double)
Converts a GDI+ font to a RenderFont with the same family name, size, style, unit and character set.
Added in ATAS 8.0.15.
public static RenderFont? ToRender(this Font? font, double dpiY = 1)
Parameters
fontFontFont to convert, can be null.
dpiYdoubleIgnored; the size is not scaled.
Returns
ToRender(Pen?)
Converts a GDI+ pen to a RenderPen: color, width, dash style, a custom dash pattern and adjustable arrow caps.
Added in ATAS 8.0.15.
public static RenderPen? ToRender(this Pen? pen)
Parameters
penPenPen to convert, can be null.
Returns
ToRender(StringFormat?)
Converts a GDI+ string format to a RenderStringFormat with the same alignment, line alignment, format flags and trimming.
Added in ATAS 8.0.15.
public static RenderStringFormat? ToRender(this StringFormat? stringFormat)
Parameters
stringFormatStringFormatFormat to convert, can be null.