Table of Contents

Class SkinHelper

Namespace
VisioForge.Core.UI.WPF.Skins
Assembly
VisioForge.Core.dll

Provides utility methods for working with the VisioForge skinning system in WPF. This static class contains helper methods for loading XAML styles, converting colors, and applying skin-specific styling to WPF controls.

public static class SkinHelper

Inheritance

Inherited Members

Remarks

The SkinHelper class bridges the gap between the VisioForge skin system and WPF by providing methods to:

  • Load XAML resource dictionaries from byte arrays
  • Convert between SkiaSharp and WPF color formats
  • Apply skin-specific styles to WPF controls

This class is essential for the WPF skin system integration and is used by various skin controls to apply consistent styling across the application.

Methods

LoadStyleDictionaryFromData(byte[])

Dynamically loads a WPF ResourceDictionary from a byte array containing XAML data.

public static ResourceDictionary LoadStyleDictionaryFromData(byte[] data)

Parameters

data byte[]

The byte array containing XAML ResourceDictionary data. This data typically comes from skin files and contains style definitions for WPF controls.

Returns

ResourceDictionary

A ResourceDictionary containing the loaded styles and resources, or null if the data is invalid or cannot be parsed.

Remarks

This method is used to load dynamic styles from skin files at runtime. The loaded ResourceDictionary can then be applied to WPF controls to change their appearance according to the active skin.

The method includes error handling and will return null if the XAML data cannot be parsed, logging any errors to the debug output.

ToColor(SKColor)

Converts a SkiaSharp SKColor to a WPF Color.

public static Color ToColor(this SKColor color)

Parameters

color SKColor

The SkiaSharp color to convert.

Returns

Color

A WPF Color with the same ARGB values as the input SKColor.

Remarks

This extension method provides seamless conversion between SkiaSharp and WPF color formats, which is essential for maintaining consistent colors across the different rendering systems used in the skinning framework.

UpdateSliderStyle(Skin, Slider, ResourceDictionary)

Updates a WPF Slider control with styles from a skin's ResourceDictionary.

public static void UpdateSliderStyle(Skin skin, Slider slider, ResourceDictionary styleDict)

Parameters

skin Skin

The skin instance containing styling information.

slider Slider

The WPF Slider control to update with new styling.

styleDict ResourceDictionary

The ResourceDictionary containing style definitions loaded from the skin.

Remarks

This method searches through the provided ResourceDictionary for a Style that targets the Slider type and applies it to the specified slider control. This allows sliders to be dynamically restyled based on the active skin.

The method safely handles null parameters and will only apply styles if both the skin and style dictionary are valid.