Brushes And Icons - AngryCarrot789/MemoryEngine360 GitHub Wiki
Brush and Icon API
This section describes the colour brush and icon API. This provides a way for plugins to create icons and use them in different parts of the application without having to ever interact with avalonia bitmaps or images directly.
Brush Manager
This service provides a mechanism for creating abstract delegates around Avalonia brushes.
CreateConstant
: creates the equivalent ofImmutableSolidColorBrush
CreateConstantLinearGradient
: creates the equivalent ofImmutableLinearGradientBrush
CreateConstantRadialGradient
: creates the equivalent ofImmutableRadialGradientBrush
GetStaticThemeBrush
: creates the equivalent ofIImmutableBrush
GetDynamicThemeBrush
is more complicated. It's a subscription based object where the front end subscribes to dynamic changes of a brush via the application'sResourcesChanged
andActualThemeVariantChanged
events. This allows, for example, an icon to use the standard glyph colour (which is white within dark themes and black within light themes, adjustable of course)
Icon Manager
Icons are managed via the IconManager
. This provides a way to creating different types of icons, such as images from the disk, bitmaps, custom geometry (SVG) and so on. When creating an icon, you provide brushes created by the BrushManager
.
Icon can be passed to context menu entries.
Accessing underlying icon pixel data is not currently implemented but is certainly possible; SVG icons for example would have to be rendered first using
RenderTargetBitmap
.