private void RemoveStyles(Theme theme) { Theme theme1 = ThemeRepository.FindTheme(theme.Name); foreach (StyleGroup styleGroup1 in theme.StyleGroups) { for (int index = theme1.StyleGroups.Count - 1; index >= 0; --index) { StyleGroup styleGroup2 = theme1.StyleGroups[index]; if (styleGroup2.IsCompatible(styleGroup1)) { theme1.StyleGroups.Remove(styleGroup2); break; } } } foreach (StyleRepository repository1 in theme.Repositories) { for (int index = theme1.Repositories.Count - 1; index >= 0; --index) { StyleRepository repository2 = theme1.Repositories[index]; if (repository2.Key == repository1.Key) { theme1.Repositories.Remove(repository2); break; } } } ThemeResolutionService.RaiseThemeChanged(theme.Name, ""); }
public static void RegisterControlStyleBuilder( string controlTypeName, string elementTypeName, StyleGroup builder, string themeName) { ThemeResolutionService.EnsureThemeRegistered(themeName); ThemeResolutionService.TripleNameKey tripleNameKey = new ThemeResolutionService.TripleNameKey(controlTypeName, elementTypeName, themeName); ThemeResolutionService.registeredBuildersByElementTypeControlType[(object)tripleNameKey] = (object)builder; ThemeResolutionService.RaiseThemeChanged(themeName, controlTypeName); }
public static void RegisterThemeRepository(XmlStyleRepository styleRepository, string themeName) { XmlStyleRepository xmlStyleRepository = ThemeResolutionService.registeredStyleRepositoriesByThemeName[(object)themeName] as XmlStyleRepository; if (xmlStyleRepository != null) { xmlStyleRepository.MergeWith(styleRepository); } else { ThemeResolutionService.registeredStyleRepositoriesByThemeName[(object)themeName] = (object)styleRepository; } ThemeResolutionService.RaiseThemeChanged(themeName, (string)null); }
public static void Remove(string themeName) { lock (ThemeRepository.lockObject) { if (ThemeRepository.registeredThemes.Contains((object)themeName)) { ThemeRepository.registeredThemes.Remove((object)themeName); } if (!ThemeRepository.themes.Contains((object)themeName)) { return; } ThemeRepository.themes.Remove((object)themeName); ThemeResolutionService.RaiseThemeChanged(themeName, (string)null); } }
public static void Add(Theme theme, bool replaceExistingStyle) { lock (ThemeRepository.lockObject) { string name = theme.Name; char[] chArray = new char[1] { ',' }; foreach (string str in name.Split(chArray)) { string themeName = str.Trim(); if (themeName == "*" || themeName == "ControlDefault") { if (theme != ThemeRepository.ControlDefault) { if (ThemeRepository.ControlDefault != null) { ThemeRepository.ControlDefault.Combine(theme, true, replaceExistingStyle); } else { ThemeRepository.controlDefault = theme; theme.MergeRepositories(); } } } else { Theme theme1 = ThemeRepository.FindTheme(themeName, false); if (theme1 != null) { if (theme != theme1) { theme1.Combine(theme, true, replaceExistingStyle); } } else { theme.MergeRepositories(); ThemeRepository.themes.Add((object)themeName, (object)theme); } } } } ThemeResolutionService.RaiseThemeChanged(theme.Name, (string)null); }
public static void ResumeThemeChange(bool raiseChanged) { lock (ThemeResolutionService.syncRoot) { if (ThemeResolutionService.themeChangeSuspendCounter > 0) { --ThemeResolutionService.themeChangeSuspendCounter; } if (ThemeResolutionService.themeChangeSuspendCounter != 0) { return; } if (raiseChanged) { foreach (ThemeResolutionService.ThemeChangeInfo themeChangeInfo in ThemeResolutionService.themesChangeDuringSuspend) { ThemeResolutionService.RaiseThemeChanged(themeChangeInfo.ThemeName, themeChangeInfo.TargetThemeClassName); } } ThemeResolutionService.themesChangeDuringSuspend.Clear(); } }
public static void ClearTheme(string themeName) { lock (ThemeResolutionService.syncRoot) { ArrayList arrayList = new ArrayList(); foreach (DictionaryEntry dictionaryEntry in ThemeResolutionService.registeredBuildersByElementTypeControlType) { ThemeResolutionService.TripleNameKey key = (ThemeResolutionService.TripleNameKey)dictionaryEntry.Key; if (string.Compare(key.Name3, themeName, true) == 0) { arrayList.Add((object)key); } } foreach (object key in arrayList) { ThemeResolutionService.registeredBuildersByElementTypeControlType.Remove(key); } arrayList.Clear(); foreach (DictionaryEntry dictionaryEntry in ThemeResolutionService.registeredBuildersByElementNameControlType) { ThemeResolutionService.TripleNameKey key = (ThemeResolutionService.TripleNameKey)dictionaryEntry.Key; if (string.Compare(key.Name3, themeName, true) == 0) { arrayList.Add((object)key); } } foreach (object key in arrayList) { ThemeResolutionService.registeredBuildersByElementNameControlType.Remove(key); } arrayList.Clear(); foreach (DictionaryEntry dictionaryEntry in ThemeResolutionService.registeredBuildersByElementTypeControlID) { ThemeResolutionService.TripleNameKey key = (ThemeResolutionService.TripleNameKey)dictionaryEntry.Key; if (string.Compare(key.Name3, themeName, true) == 0) { arrayList.Add((object)key); } } foreach (object key in arrayList) { ThemeResolutionService.registeredBuildersByElementTypeControlID.Remove(key); } arrayList.Clear(); foreach (DictionaryEntry dictionaryEntry in ThemeResolutionService.registeredBuildersDefaultByElementType) { ThemeResolutionService.TripleNameKey key = (ThemeResolutionService.TripleNameKey)dictionaryEntry.Key; if (string.Compare(key.Name3, themeName, true) == 0) { arrayList.Add((object)key); } } foreach (object key in arrayList) { ThemeResolutionService.registeredBuildersDefaultByElementType.Remove(key); } arrayList.Clear(); foreach (DictionaryEntry dictionaryEntry in ThemeResolutionService.registeredBuildersName) { string key = (string)dictionaryEntry.Key; if (string.Compare(key, themeName, true) == 0) { arrayList.Add((object)key); } } foreach (object key in arrayList) { ThemeResolutionService.registeredBuildersName.Remove(key); } } ThemeResolutionService.RaiseThemeChanged(themeName, (string)null); }
/// <summary> /// Notifies all controls that currently use this theme, to let them refresh their appearance. /// </summary> public void NotifyThemeChanged() { ThemeResolutionService.RaiseThemeChanged(this.ThemeName); }