public void SetCurrentTheme(Theme theme) { _currentTheme = theme; if (UpdateCurrentTheme != null) UpdateCurrentTheme(); }
public void LoadThemes() { string currentTheme = SettingsService.CurrentSettings != null && SettingsService.CurrentSettings.Theme != null ? SettingsService.CurrentSettings.Theme : DEFAULT_THEME; if (Directory.Exists(Path.Combine(AppHelper.CachePath, THEMES_FOLDER))) { var files = Directory.GetFiles(Path.Combine(AppHelper.CachePath, THEMES_FOLDER), "*.theme"); foreach (var file in files) { using (var fileReader = new StreamReader(file)) { try { var serializer = new XmlSerializer(typeof(Theme)); var theme = (Theme)serializer.Deserialize(fileReader); _themes.Add(theme); if (file.EndsWith(currentTheme + ".theme", StringComparison.InvariantCultureIgnoreCase)) _currentTheme = theme; } catch (Exception) { // Ignore theme parse errors } } } } if (_themes.Count == 0) _currentTheme = new Theme { Background = "#ffffff", Foreground = "#000000", Font = "Consolas", FontSize = 12 }; }