Table of Contents

Class SkinManager

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

Manages the loading, storage, and retrieval of UI skins from various sources including embedded resources, files, and folders.

public static class SkinManager

Inheritance

Inherited Members

Remarks

The VisioForge.Core.UI.Skins.SkinManager serves as the central repository for all loaded skins in the application. It provides multiple loading mechanisms:

  • Automatic loading of embedded .vfskin resources during static initialization
  • Loading from .vfskin files on disk via VisioForge.Core.UI.Skins.SkinManager.LoadFromFile(System.String)
  • Loading from directories containing skin element files via VisioForge.Core.UI.Skins.SkinManager.LoadFromFolder(System.String)
  • Loading from byte arrays via VisioForge.Core.UI.Skins.SkinManager.LoadFromData(System.String,System.Byte[])
All loading methods support ZIP-compressed skin packages (.vfskin files) which contain:
  • Settings.json - Skin metadata and color definitions
  • Element images (.svg or .png) - Visual assets for UI elements in various states
  • XAML files (.xaml) - WPF-specific templates and styles (Windows only)
Once loaded, skins can be retrieved by name using VisioForge.Core.UI.Skins.SkinManager.GetSkinByName(System.String) or enumerated using VisioForge.Core.UI.Skins.SkinManager.Skins and VisioForge.Core.UI.Skins.SkinManager.SkinNames. This class is thread-safe for read operations after initialization, but loading operations should be performed during application startup.

Methods

GetSkinByName(string)

Retrieves a specific skin by its display name.

public static Skin GetSkinByName(string name)

Parameters

name string

The display name of the skin to retrieve. This is case-sensitive and must match exactly.

Returns

Skin

The VisioForge.Core.UI.Skins.Skin instance with the matching name, or null if not found or if name is null or empty.

Remarks

This is the primary method for retrieving skins by user selection. The name must match exactly the value returned by VisioForge.Core.UI.Skins.Skin.GetName. If no skin with the specified name exists, the application should fall back to a default skin or provide appropriate error handling.

LoadFromData(string, byte[])

Loads a skin from a byte array containing ZIP-compressed skin data.

public static void LoadFromData(string name, byte[] data)

Parameters

name string

The identifier name for debugging purposes. This is not used as the skin's display name; the actual name is read from Settings.json within the ZIP archive.

data byte[]

The byte array containing the ZIP-compressed skin data (.vfskin format).

Remarks

This method is useful for loading skins from network sources, databases, or other non-file storage. The data must be a valid ZIP archive containing skin elements. If the data is not in ZIP format, the load operation is silently ignored. On load failure, the error is logged to debug output but does not throw an exception.

LoadFromFile(string)

Loads a skin from a .vfskin file on disk.

public static void LoadFromFile(string filename)

Parameters

filename string

The full path to the .vfskin file to load.

Remarks

The .vfskin file must be a valid ZIP archive containing skin elements. This method reads the entire file into memory before parsing. For large skin files, consider memory usage implications. On load failure, the error is logged to debug output but does not throw an exception. The skin's display name is read from the Settings.json file within the archive, not from the filename.

Exceptions

FileNotFoundException

Thrown if the specified file does not exist.

IOException

Thrown if the file cannot be read.

LoadFromFolder(string)

Loads a skin from a directory containing individual skin element files.

public static void LoadFromFolder(string path)

Parameters

path string

The full path to the directory containing skin element files (images, settings.json, etc.).

Remarks

This method is useful during skin development and testing, allowing skin elements to be modified without repackaging into a ZIP archive. The directory should contain:

  • Settings.json - Required file containing skin metadata and colors
  • Element image files - .svg or .png files named according to element type and state
  • XAML files - Optional .xaml files for WPF-specific templates (Windows only)
All files in the directory are processed; unrecognized files are ignored. On load failure, the error is logged to debug output but does not throw an exception.

Exceptions

DirectoryNotFoundException

Thrown if the specified directory does not exist.

UnauthorizedAccessException

Thrown if the directory cannot be accessed.

SkinNames()

Gets an array of all loaded skin names for display in UI selection lists.

public static string[] SkinNames()

Returns

string[]

An array of skin display names in the order they were loaded.

Remarks

This method is typically used to populate combo boxes, dropdown menus, or other UI selection controls that allow users to choose between available skins. The returned names correspond to the "Name" field defined in each skin's Settings.json file.

Skins()

Gets the complete list of loaded skin objects.

public static List<Skin> Skins()

Returns

List<Skin>

A list containing all loaded VisioForge.Core.UI.Skins.Skin instances.

Remarks

This method provides direct access to all skin objects for advanced scenarios where skin properties need to be examined or enumerated. For simple skin selection by name, use VisioForge.Core.UI.Skins.SkinManager.GetSkinByName(System.String) instead. The returned list is the internal collection; modifications to the list will affect the skin manager.