public static void ApplyTheme(this Form window, string themeName = null) { if (string.IsNullOrEmpty(themeName)) { themeName = "default.theme"; } if (!Path.IsPathRooted(themeName)) { themeName = Path.Combine(Application.StartupPath, themeName); } using (FileStream fs = File.OpenRead(themeName)) { ThemeStyle[] styles = ThemeParser.Parse(fs); foreach (ThemeStyle style in styles) { //System.Diagnostics.Debug.Print(style.TargetClass.Name); if (style.Target.IsAssignableFrom(window.GetType())) { style.Apply(window); } } } }
private void ParseTheme() { string themePath = Name; if (!IsResource) { if (!Path.IsPathRooted(themePath)) { themePath = Path.Combine(Application.StartupPath, themePath); } using (FileStream fs = File.OpenRead(themePath)) { Styles = ThemeParser.Parse(fs); } } else { Styles = ThemeParser.ParseResource(Name); } }