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 of ImmutableSolidColorBrush
  • CreateConstantLinearGradient: creates the equivalent of ImmutableLinearGradientBrush
  • CreateConstantRadialGradient: creates the equivalent of ImmutableRadialGradientBrush
  • GetStaticThemeBrush: creates the equivalent of IImmutableBrush
  • GetDynamicThemeBrush is more complicated. It's a subscription based object where the front end subscribes to dynamic changes of a brush via the application's ResourcesChanged and ActualThemeVariantChanged 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.