Back to Devexpress

AppearanceObject.GetForeBrush(GraphicsCache) Method

windowsforms-devexpress-dot-utils-dot-appearanceobject-dot-getforebrush-x28-devexpress-dot-utils-dot-drawing-dot-graphicscache-x29.md

latest7.7 KB
Original Source

AppearanceObject.GetForeBrush(GraphicsCache) Method

Gets the solid brush whose color is specified by the AppearanceObject.ForeColor property.

Namespace : DevExpress.Utils

Assembly : DevExpress.Utils.v25.2.dll

NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core

Declaration

csharp
public Brush GetForeBrush(
    GraphicsCache cache
)
vb
Public Function GetForeBrush(
    cache As GraphicsCache
) As Brush

Parameters

NameTypeDescription
cacheGraphicsCache

A GraphicsCache object that provides access to the pens and brushes used for painting.

|

Returns

TypeDescription
Brush

A Brush descendant representing a brush specified by the appearance object’s settings.

|

Remarks

If the cache parameter’s value is not a null reference, the GetForeBrush method uses the GraphicsCache object to obtain the solid brush whose color is specified by the foreground color settings of the current appearance object. This lets you obtain the brush more quickly, since it may already be stored within the cache. Otherwise, a new System.Drawing.SolidBrush object with appropriate settings is created and returned.

Use the AppearanceOptions.UseForeColor to obtain the foreground color specified by the appearance object’s settings.

The following code snippets (auto-collected from DevExpress Examples) contain references to the GetForeBrush(GraphicsCache) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-custom-buttonedit-display-editvalue-on-button/CS/TestMyButtonEdit/MyButtonEditPainter.cs#L42

csharp
bounds = new Rectangle(bounds.X, bounds.Y, text_width, bounds.Height);
    appearance.DrawString(info.Cache, text, bounds, appearance.GetForeBrush(info.Cache), appearance.GetTextOptions().GetStringFormat(info.ViewInfo.DefaultTextOptions));
}

winforms-grid-show-editor-buttons-on-cell-hover/CS/WindowsApplication3/Form1.cs#L48

csharp
info.EditorButtonPainter.DrawObject(args);
e.Cache.DrawString(e.DisplayText, e.Appearance.Font, e.Appearance.GetForeBrush(e.Cache), textRect, e.Appearance.GetStringFormat());
e.Handled = true;

winforms-xtraform-center-caption/CS/WindowsApplication1/Custom Form Painter/CustomFormPainter.cs#L43

csharp
DrawTextShadow(cache, appearance, r);
    cache.DrawString(text, appearance.Font, appearance.GetForeBrush(cache), r, appearance.GetStringFormat());
}

winforms-combobox-with-close-and-clear-buttons-in-dropdown/CS/WindowsApplication3/CustomPopupBaseSizeableFormPainter.cs#L29

csharp
if (rect.IsEmpty) return;
Brush br = app.GetForeBrush(cache);
if (isHot)

winforms-grid-display-custom-rows/CS/CustomRowInGrid/CustomRowInGrid/BlankItem.cs#L40

csharp
drawRect.Inflate(-3, -3);
    e.Cache.DrawString(Text, gri.Appearance.Font, gri.Appearance.GetForeBrush(e.Cache), drawRect, gri.Appearance.GetStringFormat());
}

winforms-custom-buttonedit-display-editvalue-on-button/VB/TestMyButtonEdit/MyButtonEditPainter.vb#L41

vb
bounds = New Rectangle(bounds.X, bounds.Y, text_width, bounds.Height)
    appearance.DrawString(info.Cache, text, bounds, appearance.GetForeBrush(info.Cache), appearance.GetTextOptions().GetStringFormat(info.ViewInfo.DefaultTextOptions))
End Sub

winforms-grid-show-editor-buttons-on-cell-hover/VB/WindowsApplication3/Form1.vb#L51

vb
info.EditorButtonPainter.DrawObject(args)
e.Cache.DrawString(e.DisplayText, e.Appearance.Font, e.Appearance.GetForeBrush(e.Cache), textRect, e.Appearance.GetStringFormat())
e.Handled = True

winforms-xtraform-center-caption/VB/WindowsApplication1/Custom Form Painter/CustomFormPainter.vb#L49

vb
DrawTextShadow(cache, appearance, r)
    cache.DrawString(text, appearance.Font, appearance.GetForeBrush(cache), r, appearance.GetStringFormat())
End Sub

winforms-combobox-with-close-and-clear-buttons-in-dropdown/VB/WindowsApplication3/CustomPopupBaseSizeableFormPainter.vb#L26

vb
If rect.IsEmpty Then Return
Dim br As Brush = app.GetForeBrush(cache)
If isHot Then

winforms-grid-display-custom-rows/VB/CustomRowInGrid/BlankItem.vb#L39

vb
drawRect.Inflate(-3, -3)
    e.Cache.DrawString(Text, gri.Appearance.Font, gri.Appearance.GetForeBrush(e.Cache), drawRect, gri.Appearance.GetStringFormat())
End Sub

See Also

GetForeColor

ForeColor

GetForePen(GraphicsCache)

AppearanceObject Class

AppearanceObject Members

DevExpress.Utils Namespace