using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace NexusPowerControl { public interface IThemeLoader { bool LoadThemeOrDefault(string ThemeName); //bool LoadCustomTheme(string ThemeName, string ThemeXml); ThemeLoader.ThemeDefinition GetLoadedTheme(); } public class ThemeLoader : IThemeLoader { private ThemeLoader.ThemeDefinition LoadedTheme; public ThemeLoader() { this.LoadedTheme = new ThemeDefinition(); this.LoadThemeOrDefault(ThemeDefinition.DefaultTheme); } #region IThemeLoader Members public bool LoadThemeOrDefault(string ThemeName) { this.LoadedTheme = new ThemeDefinition(ThemeName); return LoadedTheme.ThemeLoaded; } public ThemeLoader.ThemeDefinition GetLoadedTheme() { return (this.LoadedTheme == null) ? new ThemeDefinition() : this.LoadedTheme; } #endregion #region sub-classes public class ThemeDefinition { private const string ThemeDirectory = "theme"; public const string DefaultTheme = "AeroLowRes"; public ThemeDefinition() : this(ThemeDefinition.DefaultTheme) { } public ThemeDefinition(string ThemeXml) { this.LoadTheme(ThemeXml); } private void LoadTheme(string theme) { if (theme.ToLower().Contains(".xml")) { this.LoadCustomTheme(theme); } else { this.LoadStandardTheme(theme); } } private void LoadStandardTheme(string theme) { // load theme in format: theme//theme.xml : will throw file not found excetion (use default) } private void LoadCustomTheme(string theme) { // load theme in format: : will throw file not found excetion (use default) } public bool ThemeLoaded { get; set; } } #endregion } }