public override void Initialize(IConfig config) { // Prepare disposables _disposables?.Dispose(); _disposables = new CompositeDisposable(); AvailableThemeAccents.Clear(); foreach (var themeAccent in Enum.GetValues(typeof(ThemeAccents)).Cast <ThemeAccents>()) { var translation = themeAccent.EnumValueOf(); AvailableThemeAccents.Add(new Tuple <ThemeAccents, string>(themeAccent, translation)); } AvailableThemes.Clear(); foreach (var theme in Enum.GetValues(typeof(Themes)).Cast <Themes>()) { var translation = theme.EnumValueOf(); AvailableThemes.Add(new Tuple <Themes, string>(theme, translation)); } // Place this under the Ui parent ParentId = "Ui"; // Make sure Commit/Rollback is called on the UiConfiguration config.Register(MetroConfiguration); // automatically update the DisplayName _disposables.Add(UiTranslations.CreateDisplayNameBinding(this, nameof(IUiTranslations.Theme))); base.Initialize(config); }
public void Reset() { var accent = Settings.GetById(SettingKeys.Accent).Value; var theme = Settings.GetById(SettingKeys.Theme).Value; SelectedAccent = AvailableAccents.FirstOrDefault(a => a.Name == accent); SelectedTheme = AvailableThemes.FirstOrDefault(t => t.Name == theme); ExpandEntries = Settings.GetById(SettingKeys.ExpandEntries).Get <bool>(); StartMinimized = Settings.GetById(SettingKeys.StartMinimized).Get <bool>(); StartWithWindows = Settings.GetById(SettingKeys.StartWithWindows).Get <bool>(); CloseToTray = Settings.GetById(SettingKeys.CloseToTray).Get <bool>(); var lang = Settings.GetById(SettingKeys.Language).Value; ChangeLanguage = false; SelectedLanguage = AvailableLanguages.FirstOrDefault(l => l.IetfLanguageTag.Equals(lang)) ?? AvailableLanguages.FirstOrDefault(l => l.IetfLanguageTag.Equals("en-US")); ChangeLanguage = true; var path = Settings.GetById(SettingKeys.DatabasePath)?.Value; if (string.IsNullOrWhiteSpace(path)) { path = Constants.DefaultDatabasePath; } DatabasePath = path; }
private static void LoadTheme(string themeName) { var resourcesToLoad = new List <Uri>(3) { new Uri($"pack://application:,,,/Nodify;component/Themes/{themeName}.xaml"), new Uri($"pack://application:,,,/Nodify.Shared;component/Themes/{themeName}.xaml") }; var assemblyName = Assembly.GetEntryAssembly()?.GetName().Name; if (assemblyName != null) { resourcesToLoad.Add(new Uri($"pack://application:,,,/{assemblyName};component/Themes/{themeName}.xaml")); } foreach (var theme in resourcesToLoad) { try { var resource = new ThemeDictionary { Source = theme, ThemeName = themeName }; Application.Current.Resources.MergedDictionaries.Add(resource); } catch { } } ActiveTheme = themeName; AvailableThemes.Add(themeName); }
public TournamentThemes(Culture culture) { AvailableThemes.AddRange(_generic); switch (culture) { case Culture.Aserai: AvailableThemes.AddRange(_aserai); break; case Culture.Battania: AvailableThemes.AddRange(_battania); break; case Culture.Empire: AvailableThemes.AddRange(_empire); break; case Culture.Khuzait: AvailableThemes.AddRange(_khuzait); break; case Culture.Sturgia: AvailableThemes.AddRange(_sturgia); break; case Culture.Vlandia: AvailableThemes.AddRange(_vlandia); break; default: break; } }
public SettingsWindowViewmodel(MainWindow main, AppSettings data) { mainWindow = main; Settings = data; ShortcutList = ShortcutManager.ListObservableShortcuts(data); AvailableThemes = App.Themes.GetAllAvailableThemes(); AvailableModifier = App.Themes.GetAllAvailableModifier().Select(m => new CheckableAlephTheme { Theme = m, Owner = this, Checked = data.ThemeModifier.Contains(m.SourceFilename) }).ToList(); _selectedTheme = App.Themes.GetThemeByFilename(Settings.Theme, out _) ?? App.Themes.GetDefault() ?? AvailableThemes.FirstOrDefault() ?? App.Themes.GetFallback(); _oldTheme = ThemeManager.Inst.CurrentBaseTheme; _oldModifiers = ThemeManager.Inst.CurrentModifers.ToList(); SnippetList = new ObservableCollectionNoReset <EditableSnippet>(data.Snippets.Data.Select(p => new EditableSnippet { PreviewFunc = SnippetPrev, ID = p.Key, Name = p.Value.DisplayName, Value = p.Value.Value })); NewSnippetID = GetNextSnippetID(); }
public override void Initialize(IConfig config) { // Prepare disposables _disposables?.Dispose(); _disposables = new CompositeDisposable(); AvailableThemeAccents.Clear(); foreach (var themeAccent in Enum.GetValues(typeof(ThemeAccents)).Cast <ThemeAccents>()) { var translation = themeAccent.EnumValueOf(); AvailableThemeAccents.Add(new Tuple <ThemeAccents, string>(themeAccent, translation)); } AvailableThemes.Clear(); foreach (var theme in Enum.GetValues(typeof(Themes)).Cast <Themes>()) { var translation = theme.EnumValueOf(); AvailableThemes.Add(new Tuple <Themes, string>(theme, translation)); } // Place this under the Ui parent ParentId = nameof(ConfigIds.Ui); // Make sure Commit/Rollback is called on the IUiConfiguration config.Register(MetroConfiguration); // automatically update the DisplayName var greenshotLanguageBinding = GreenshotLanguage.CreateDisplayNameBinding(this, nameof(IGreenshotLanguage.SettingsTitle)); // Make sure the greenshotLanguageBinding is disposed when this is no longer active _disposables.Add(greenshotLanguageBinding); base.Initialize(config); }
public SettingsWindowViewmodel(MainWindow main, AppSettings data) { mainWindow = main; Settings = data; ShortcutList = ShortcutManager.ListObservableShortcuts(data); AvailableThemes = App.Themes.GetAllAvailable(); _selectedTheme = App.Themes.GetByFilename(Settings.Theme, out _) ?? App.Themes.GetByFilename("default.xml", out _) ?? AvailableThemes.FirstOrDefault() ?? App.Themes.GetFallback(); }
public async Task <bool> TrySetCurrentThemeAsync(string theme, HttpContext httpContext) { if (!AvailableThemes.Contains(theme)) { return(false); } if (!_themeProvider.GetThemes().Contains(theme)) { _logger.ThemeNotAvailable(theme, _themeProvider.GetThemePath(ThemeProvider.ThemesBasePath, theme)); } await SetCurrentThemeAsync(theme, httpContext); return(true); }
public static void SetNextTheme() { if (ActiveTheme != null) { var themes = AvailableThemes.ToList(); var i = themes.IndexOf(ActiveTheme); var next = i + 1 == themes.Count ? 0 : i + 1; SetTheme(themes[next]); } else if (AvailableThemes.Count > 0) { SetTheme(AvailableThemes.First()); } }
static ThemeManager() { var themes = new Dictionary <Uri, string>(); AvailableThemes.ForEach(themeName => themes.Add(new Uri($"pack://application:,,,/Nodify;component/Themes/{themeName}.xaml"), themeName)); foreach (var d in Application.Current.Resources.MergedDictionaries) { if (themes.TryGetValue(d.Source, out var theme)) { ActiveTheme = theme; } } SetNextThemeCommand = new DelegateCommand(SetNextTheme); }
/// <inheritdoc /> public override void Initialize(IConfig config) { // Prepare disposables _disposables?.Dispose(); _disposables = new CompositeDisposable(); AvailableThemes.Clear(); foreach (var theme in MetroThemeManager.AvailableThemes) { AvailableThemes.Add(theme); } foreach (var themeColor in MetroThemeManager.AvailableThemeColors) { AvailableThemeColors.Add(themeColor); } // Place this under the Ui parent ParentId = "Ui"; // Make sure Commit/Rollback is called on the UiConfiguration config.Register(MetroConfiguration); // automatically update the DisplayName _disposables.Add(UiTranslations.CreateDisplayNameBinding(this, nameof(IUiTranslations.Theme))); // Automatically show theme changes _disposables.Add( MetroConfiguration.OnPropertyChanging(nameof(MetroConfiguration.Theme)).Subscribe(args => { if (args is PropertyChangingEventArgsEx propertyChangingEventArgsEx) { _metroThemeManager.ChangeTheme(propertyChangingEventArgsEx.NewValue as string, null); } }) ); _disposables.Add( MetroConfiguration.OnPropertyChanging(nameof(MetroConfiguration.ThemeColor)).Subscribe(args => { if (args is PropertyChangingEventArgsEx propertyChangingEventArgsEx) { _metroThemeManager.ChangeTheme(null, propertyChangingEventArgsEx.NewValue as string); } }) ); base.Initialize(config); }
public async Task ReloadThemes() { IsLoading = true; var availableThemes = new List <Theme>(); var selectedThemeNames = App.LocalSettings.Read("SelectedThemeNames", new List <string>()); var availableThemeNames = App.LocalSettings.Read("AvailableThemeNames", new List <string>()); var themeDirectory = await ApplicationData.Current.LocalFolder.CreateFolderAsync("Themes", CreationCollisionOption.OpenIfExists); var directories = await themeDirectory.GetFoldersAsync(); foreach (var directory in directories) { if (await directory.TryGetItemAsync("theme.json") is StorageFile themeJson) { try { var theme = JsonConvert.DeserializeObject <Theme>(await FileIO.ReadTextAsync(themeJson)); availableThemes.Add(theme); if (!availableThemeNames.Contains(theme.NormalisedName)) { availableThemeNames.Add(theme.NormalisedName); } } catch { } } } AvailableThemes.Clear(); foreach (var theme in availableThemes.OrderBy(t => availableThemeNames.IndexOf(t.NormalisedName))) { AvailableThemes.Add(theme); } SelectedThemes.Clear(); foreach (var theme in availableThemes.Where(t => selectedThemeNames.Contains(t.NormalisedName))) { SelectedThemes.Add(theme); } IsLoading = false; InvokePropertyChanged(nameof(ShowThemesPlaceholder)); App.LocalSettings.Save("AvailableThemeNames", availableThemeNames); }
/// <summary> /// To be called after setting _userSuppliedMap /// </summary> private async Task BuildAndApplySubsetMap() { if (_userSuppliedMap == null) { return; } // Clear existing map _subsetMap = null; // update list of available themes AvailableThemes = await ThemeResponsiveMapUtilities.ThemesFromMap(_userSuppliedMap); var systemTheme = _themeOracle.GetCurrentSystemTheme(); // Try to build map for selected theme if (SelectedTheme == "Automatic" && AvailableThemes.Contains(systemTheme)) { _subsetMap = await ThemeResponsiveMapUtilities.ThemedSubsetFromThemeAwareMap(_userSuppliedMap, systemTheme); } else if (AvailableThemes.Contains(SelectedTheme)) { _subsetMap = await ThemeResponsiveMapUtilities.ThemedSubsetFromThemeAwareMap(_userSuppliedMap, SelectedTheme); } // Fall back to fallback theme else if (AvailableThemes.Contains(FallbackTheme)) { _subsetMap = await ThemeResponsiveMapUtilities.ThemedSubsetFromThemeAwareMap(_userSuppliedMap, FallbackTheme); } // Fall back to first theme else if (AvailableThemes.Any()) { _subsetMap = await ThemeResponsiveMapUtilities.ThemedSubsetFromThemeAwareMap(_userSuppliedMap, AvailableThemes.First()); } // Fall back to input map else { _subsetMap = _userSuppliedMap; } _subsetMap.InitialViewpoint = GetCurrentViewpoint(ViewpointType.BoundingGeometry); // update map base.Map = _subsetMap; }
private void OnAvailableThemesUpdated(object sender, NotifyCollectionChangedEventArgs e) { App.LocalSettings.Save("AvailableThemeNames", AvailableThemes.ToList().Select(t => t.NormalisedName)); }
public void LoadTheme(string name) { Theme theme = AvailableThemes.First(x => string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase)); LoadTheme(theme); }