Search Framework:
PenBrushFactory
Namespace: WealthLab.WPF
Parent: Object

The PenBrushFactory class is a static utility that creates and caches WPF Pen and Brush objects. It also exposes colors and brushes derived from the currently selected WL9 Theme. Repeated requests for the same WLColor-based Brush or the same Pen definition reuse cached objects instead of creating new instances.

Building Block Brushes
BBBackgroundBrush
public static SolidColorBrush BBBackgroundBrush

Returns the Brush used for Building Block backgrounds in the currently initialized WL9 Theme.


BBConditionBrush
public static SolidColorBrush BBConditionBrush

Returns the Brush used for Building Block condition elements in the currently initialized WL9 Theme.


BBLongEntryBrush
public static SolidColorBrush BBLongEntryBrush

Returns the Brush used for Building Block long-entry elements in the currently initialized WL9 Theme.


BBLongExitBrush
public static SolidColorBrush BBLongExitBrush

Returns the Brush used for Building Block long-exit elements in the currently initialized WL9 Theme.


BBQualifierBrush
public static SolidColorBrush BBQualifierBrush

Returns the Brush used for Building Block qualifier elements in the currently initialized WL9 Theme.


BBShortEntryBrush
public static SolidColorBrush BBShortEntryBrush

Returns the Brush used for Building Block short-entry elements in the currently initialized WL9 Theme.


BBShortExitBrush
public static SolidColorBrush BBShortExitBrush

Returns the Brush used for Building Block short-exit elements in the currently initialized WL9 Theme.



Methods
GetBrush
public static Brush GetBrush(WLColor color)

Returns a WPF Brush for the specified color. The returned Brush is cached, so subsequent calls using the same WLColor return the existing Brush instance.


GetPen
public static Pen GetPen(
WLColor color,
double thickness = 1.0,
LineStyle ls = LineStyle.Solid)
public static Pen GetPen(
WLColor color,
LineStyle ls)

Returns a WPF Pen using the specified color. The first overload optionally lets you specify the Pen's thickness and line style. The second overload creates a Pen using the specified color and ls with a thickness of 1. The supported LineStyle values are rendered as follows:

  • Solid - Solid line.
  • Dotted - Uses WPF DashStyles.Dot.
  • Dashed - Uses WPF DashStyles.Dash. Pen instances are cached according to their color, thickness, and line style.

Initialize
public static void Initialize(Window w)

Initializes the theme-dependent colors and brushes exposed by PenBrushFactory using resources from the specified WPF Window. This method initializes the red, green, yellow, foreground, background, Building Block, and blue status brushes. If the Window is null or does not contain the expected RedText resource, the method returns without initializing the properties.


ProfitBrush
public static SolidColorBrush ProfitBrush(double profit)

Returns a theme-aware Brush based on the specified profit value.

  • A positive value returns GreenTextBrush.
  • A negative value returns RedTextBrush.
  • Zero returns ForegroundBrush.


Other Brushes
BlueStatusBrush
public static SolidColorBrush BlueStatusBrush

Returns the blue status text Brush from the currently initialized WL9 Theme. It is used by WL9 for status rendering such as the Strategy Monitor.



Theme Brushes
BackgroundBrush
public static SolidColorBrush BackgroundBrush

Returns the background SolidColorBrush of the currently initialized WL9 Theme.


ForegroundBrush
public static SolidColorBrush ForegroundBrush

Returns the foreground SolidColorBrush of the currently initialized WL9 Theme.


GreenTextBrush
public static SolidColorBrush GreenTextBrush

Returns the green text SolidColorBrush of the currently initialized WL9 Theme.


RedTextBrush
public static SolidColorBrush RedTextBrush

Returns the red text SolidColorBrush of the currently initialized WL9 Theme.


YellowTextBrush
public static SolidColorBrush YellowTextBrush

Returns the yellow text SolidColorBrush of the currently initialized WL9 Theme.



Theme Colors
BackgroundColor
public static WLColor BackgroundColor

Returns the background color of the currently initialized WL9 Theme.


ForegroundColor
public static WLColor ForegroundColor

Returns the foreground color of the currently initialized WL9 Theme.


GreenColor
public static WLColor GreenColor

Returns the green text color of the currently initialized WL9 Theme.


RedColor
public static WLColor RedColor

Returns the red text color of the currently initialized WL9 Theme.


YellowColor
public static WLColor YellowColor

Returns the yellow text color of the currently initialized WL9 Theme.