Class ThemeResolutionService
Provides centralized theme management and resolution services for RadControls applications.
Inheritance
Inherited Members
Namespace: Telerik.WinControls
Assembly: Telerik.WinControls.dll
Syntax
public class ThemeResolutionService
Remarks
ThemeResolutionService acts as the central repository for managing themes, style sheets, and their relationships within a RadControls application. It handles theme registration, resolution, and application to controls based on their type and configuration.
The service manages StyleSheet objects that define the visual appearance and behavior of RadControls and RadElements, along with StyleSheetRelation objects that map specific controls to their appropriate style sheets.
RadControls automatically query this service during initialization using their ThemeName property to retrieve and apply the appropriate StyleSheet. The service supports theme inheritance, cascading styles, and dynamic theme switching at runtime.
This class provides APIs for registering themes, unregistering themes, querying theme storage by various attributes such as name and target class, and managing theme relationships throughout the application lifecycle.
Constructors
ThemeResolutionService()
Declaration
public ThemeResolutionService()
Fields
TelerikFluentIconsFontName
Declaration
public static string TelerikFluentIconsFontName
Field Value
|
System.String
|
TelerikWebUIFontName
Declaration
public static string TelerikWebUIFontName
Field Value
|
System.String
|
WebComponentsIconsFontName
Declaration
public static string WebComponentsIconsFontName
Field Value
|
System.String
|
Properties
AllowAnimations
Determines whether animations are allowed across entire application.
Declaration
public static bool AllowAnimations { get; set; }
Property Value
|
System.Boolean
|
ApplicationThemeName
Gets or sets value indicating the theme name that will be used by all controls in the application.
Declaration
public static string ApplicationThemeName { get; set; }
Property Value
|
System.String
|
Remarks
If the value of this property is null or empty each control will be assigned a theme, corresponding on the ThemeName property of the control. Otherwise the ThemeName property will be disregarded. If a specific control in the application has no theme registered with the name specified by ApplicationThemeName, it will be assigned its ControlDefault theme name.
ControlDefaultThemeName
"ControlDefault" theme name
Declaration
public static string ControlDefaultThemeName { get; set; }
Property Value
|
System.String
|
SystemThemeName
Declaration
public static string SystemThemeName { get; }
Property Value
|
System.String
|
Methods
ApplyThemeToControlTree(Control, String)
Applies the specified ThemeName to all RadControls that are children of the specified Control and its child Controls
Declaration
public static void ApplyThemeToControlTree(Control control, string themeName)
Parameters
|
System.Windows.Forms.Control
control
|
|
System.String
themeName
|
ClearTheme(String)
Clears all stylesheets registered previously with the themeName specified.
Declaration
public static void ClearTheme(string themeName)
Parameters
|
System.String
themeName
|
EnsureThemeRegistered(String)
Creates and registers an empty Theme if one is not already registered.
Declaration
public static Theme EnsureThemeRegistered(string themeName)
Parameters
|
System.String
themeName
|
Returns
|
Theme
|
GetAvailableThemes()
Gets a list of all registered themes.
Declaration
public static ICollection GetAvailableThemes()
Returns
|
System.Collections.ICollection
|
GetAvailableThemes(IComponentTreeHandler)
Gets any themes registered for a specific control by control type name or control name.
Declaration
public static List<Theme> GetAvailableThemes(IComponentTreeHandler control)
Parameters
|
IComponentTreeHandler
control
|
Returns
|
System.Collections.Generic.List<Theme>
|
GetCustomFont(String)
Returns a previously loaded font by given font name.
Declaration
public static FontFamily GetCustomFont(string fontName)
Parameters
|
System.String
fontName
The name of font. |
Returns
|
System.Drawing.FontFamily
The FontFamily or null if font with given name is not loaded. |
GetCustomFonts()
Declaration
public static FontFamily[] GetCustomFonts()
Returns
|
System.Drawing.FontFamily[]
|
GetFont(String, Single, FontStyle)
Returns a font by given font name. The font can be custom(loaded in memory) or installed on the machine.
Declaration
public static Font GetFont(string fontName, float fontSize, FontStyle fontStyle)
Parameters
|
System.String
fontName
The name of the font or custom font. |
|
System.Single
fontSize
The size of the font. |
|
System.Drawing.FontStyle
fontStyle
|
Returns
|
System.Drawing.Font
The Font or the default font if font with given name is not valid. |
GetStyleSheetBuilder(IComponentTreeHandler, String, String, String)
Declaration
public static StyleGroup GetStyleSheetBuilder(IComponentTreeHandler control, string elementTypeFullName, string elementName, string proposedThemeName)
Parameters
|
IComponentTreeHandler
control
|
|
System.String
elementTypeFullName
|
|
System.String
elementName
|
|
System.String
proposedThemeName
|
Returns
|
StyleGroup
|
GetStyleSheetBuilder(RadElement)
Declaration
public static StyleGroup GetStyleSheetBuilder(RadElement element)
Parameters
|
RadElement
element
|
Returns
|
StyleGroup
|
GetStyleSheetBuilder(RadElement, String)
Declaration
public static StyleGroup GetStyleSheetBuilder(RadElement element, string proposedThemeName)
Parameters
|
RadElement
element
|
|
System.String
proposedThemeName
|
Returns
|
StyleGroup
|
GetStyleSheetBuilders(String)
Gets all StyleSheets registered under a theme name.
Declaration
public static StyleGroup[] GetStyleSheetBuilders(string themeName)
Parameters
|
System.String
themeName
|
Returns
|
StyleGroup[]
|
GetTheme(String)
Get previously registered theme by theme name.
Declaration
public static Theme GetTheme(string themeName)
Parameters
|
System.String
themeName
|
Returns
|
Theme
|
GetThemeRepository(String, Boolean, Boolean)
Declaration
public static XmlStyleRepository GetThemeRepository(string themeName, bool useAsterikTheme, bool useAppThemeName)
Parameters
|
System.String
themeName
|
|
System.Boolean
useAsterikTheme
|
|
System.Boolean
useAppThemeName
|
Returns
|
XmlStyleRepository
|
LoadFont(Stream)
Declaration
public static int LoadFont(Stream fontStream)
Parameters
|
System.IO.Stream
fontStream
|
Returns
|
System.Int32
|
LoadFont(String)
Declaration
public static int LoadFont(string resourcePath)
Parameters
|
System.String
resourcePath
|
Returns
|
System.Int32
|
LoadPackageFile(String)
Loads a theme package, stored in the provided file.
Declaration
public static bool LoadPackageFile(string filePath)
Parameters
|
System.String
filePath
|
Returns
|
System.Boolean
|
LoadPackageFile(String, Boolean)
Loads a theme package stored in the provided file.
Declaration
public static bool LoadPackageFile(string filePath, bool throwOnError)
Parameters
|
System.String
filePath
|
|
System.Boolean
throwOnError
True to throw an exception if it occurs, false otherwise. |
Returns
|
System.Boolean
|
LoadPackageResource(Assembly, String)
Loads a theme package from an embedded resource in the specified assembly.
Declaration
public static bool LoadPackageResource(Assembly sourceAssembly, string resourcePath)
Parameters
|
System.Reflection.Assembly
sourceAssembly
|
|
System.String
resourcePath
|
Returns
|
System.Boolean
|
LoadPackageResource(String)
Loads a theme package, stored in the provided embedded resource. The calling assembly is used to read the manifest resource stream.
Declaration
public static bool LoadPackageResource(string resourcePath)
Parameters
|
System.String
resourcePath
|
Returns
|
System.Boolean
|
LoadPackageResource(ThemeResolutionService.ResourceParams, Boolean)
Loads a theme package stored in the provided embedded resource.
Declaration
public static bool LoadPackageResource(ThemeResolutionService.ResourceParams resourceParams, bool throwOnError)
Parameters
|
ThemeResolutionService.ResourceParams
resourceParams
|
|
System.Boolean
throwOnError
True to throw an exception if it occurs, false otherwise. |
Returns
|
System.Boolean
|
RaiseThemeChanged(String, String)
Declaration
public static void RaiseThemeChanged(string themeName, string controlThemeClassName)
Parameters
|
System.String
themeName
|
|
System.String
controlThemeClassName
|
RegisterControlStyleBuilder(String, String, StyleGroup, String)
Registers a StyleBuilder for specific type of controls and specific type of elements under the name given.
Declaration
public static void RegisterControlStyleBuilder(string controlTypeName, string elementTypeName, StyleGroup builder, string themeName)
Parameters
|
System.String
controlTypeName
|
|
System.String
elementTypeName
|
|
StyleGroup
builder
|
|
System.String
themeName
|
RegisterDarkTheme(String)
Registers a theme as dark, by its theme name.
Declaration
public static void RegisterDarkTheme(string themeName)
Parameters
|
System.String
themeName
The name of the theme. |
RegisterElementTypeDefaultStyleBuilder(String, String, StyleGroup)
Declaration
public static void RegisterElementTypeDefaultStyleBuilder(string themeName, string elementTypeName, StyleGroup builder)
Parameters
|
System.String
themeName
|
|
System.String
elementTypeName
|
|
StyleGroup
builder
|
RegisterStyleBuilder(StyleGroup, String)
Registers a StyleSheet found in styleBuilderRegistration using also the registration details specified under the theme name specified.
Declaration
public static void RegisterStyleBuilder(StyleGroup styleBuilderRegistration, string themeName)
Parameters
|
StyleGroup
styleBuilderRegistration
|
|
System.String
themeName
|
RegisterStyleBuilderByControlName(String, String, StyleGroup, String)
Declaration
public static void RegisterStyleBuilderByControlName(string controlName, string elementTypeName, StyleGroup builder, string themeName)
Parameters
|
System.String
controlName
|
|
System.String
elementTypeName
|
|
StyleGroup
builder
|
|
System.String
themeName
|
RegisterThemeFromStorage(ThemeStorageType, Assembly, String)
Registers theme from a file or resource that contains a XML-serialized Theme object. The Visual Style Builder application for example is capable of designing and serializing themes. Theme files generally contain Theme with one or several style sheets each assigned a registration that defines which RadControl and/or RadElment the style sheet applies.
Declaration
public static void RegisterThemeFromStorage(ThemeStorageType storageType, Assembly assembly, string themeLocation)
Parameters
|
ThemeStorageType
storageType
|
|
System.Reflection.Assembly
assembly
|
|
System.String
themeLocation
|
RegisterThemeFromStorage(ThemeStorageType, String)
Registers theme from a file or resource that contains a XML-serialized Theme object. The Visual Style Builder application for example is capable of designing and serializing themes. Theme files generally contain Theme with one or several style sheets each assigned a registration that defines which RadControl and/or RadElment the style sheet applies.
Declaration
public static void RegisterThemeFromStorage(ThemeStorageType storageType, string themeLocation)
Parameters
|
ThemeStorageType
storageType
|
|
System.String
themeLocation
|
RegisterThemeFromStorage(ThemeStorageType, ThemeResolutionService.ResourceParams)
Registers theme from a file or resource that contains a XML-serialized Theme object. The Visual Style Builder application for example is capable of designing and serializing themes. Theme files generally contain Theme with one or several style sheets each assigned a registration that defines which RadControl and/or RadElment the style sheet applies.
Declaration
public static void RegisterThemeFromStorage(ThemeStorageType storageType, ThemeResolutionService.ResourceParams resourceParams)
Parameters
|
ThemeStorageType
storageType
|
|
ThemeResolutionService.ResourceParams
resourceParams
|
RegisterThemeRepository(XmlStyleRepository, String)
Declaration
public static void RegisterThemeRepository(XmlStyleRepository styleRepository, string themeName)
Parameters
|
XmlStyleRepository
styleRepository
|
|
System.String
themeName
|
RemoveThemeRegistration(String)
Declaration
public static void RemoveThemeRegistration(string themeName)
Parameters
|
System.String
themeName
|
ResumeThemeChange()
Resumes the ThemeChange event. This method is used internally.
Declaration
public static void ResumeThemeChange()
ResumeThemeChange(Boolean)
Resumes the ThemeChange event. This method is used internally.
Declaration
public static void ResumeThemeChange(bool raiseChanged)
Parameters
|
System.Boolean
raiseChanged
Determines whether to fire the ThemeChanged event. |
SubscribeForThemeChanged(IThemeChangeListener)
Call to subscribe for theme change event, for the specified control theme class name. Note the event may be fired from another thread
Declaration
public static void SubscribeForThemeChanged(IThemeChangeListener listener)
Parameters
|
IThemeChangeListener
listener
|
SuspendThemeChange()
Suspends the ThemeChange event. This method is used internally.
Declaration
public static void SuspendThemeChange()
UnregisterStyleSheetBuilder(StyleGroup)
Removes an instance of the StyleGroup class from the dictionaries with registered style builders.
Declaration
public static void UnregisterStyleSheetBuilder(StyleGroup builder)
Parameters
|
StyleGroup
builder
The instance to remove. |
UnsubscribeFromThemeChanged(IThemeChangeListener)
Call to unsubscribe for theme change event.
Declaration
public static void UnsubscribeFromThemeChanged(IThemeChangeListener listener)
Parameters
|
IThemeChangeListener
listener
|
Events
ApplicationThemeChanged
Declaration
public static event ThemeChangedHandler ApplicationThemeChanged
Event Type
|
ThemeChangedHandler
|
ResolveStyleBuilder
Declaration
public static event ResolveStyleBuilderEventHandler ResolveStyleBuilder
Event Type
|
ResolveStyleBuilderEventHandler
|