public void ApplyChanges() { Properties.Settings.Default.ThemeName = SelectedTheme.GetType().Name; Properties.Settings.Default.AutoHideMainMenu = AutoHideMainMenu; Properties.Settings.Default.LanguageCode = SelectedLanguage; Properties.Settings.Default.Save(); }
private void ApplyButton_Click(object sender, RoutedEventArgs e) { if (SelectedTheme == null) { return; } if (!SelectedTheme.IsExtracted || ForceExtraction) { if (!SelectedTheme.Extract()) { MessageBox.Show(String.Format(Strings.ExtractionError, Configuration.GamePath, Configuration.ThemeDirPath), Strings.Error, MessageBoxButton.OK, MessageBoxImage.Exclamation); } } if (SelectedTheme.Apply()) { MessageBox.Show(Strings.ApplySuccess, Strings.Success, MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show(Strings.ApplyFailed, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Information); } }
public AppearanceManagerViewModel(IAppearanceSettings settings) { _settings = settings; _themes = new ObservableCollection <ThemeResource>(AppearanceManager.GetThemes()); _selectedTheme = (from t in _themes where t.Name == _settings.Theme select t).FirstOrDefault(); if (_selectedTheme == null) { SelectedTheme = CurrentTheme; } SelectedTheme.Apply(); _accents = new ObservableCollection <AccentResource>(AppearanceManager.GetAccents()); _accentGroups = new ObservableCollection <string>((from a in _accents orderby a.SortOrder ascending select a.AccentGroup).Distinct().ToList()); _accentGroupings = new CollectionViewSource { Source = _accents }; _accentGroupings.Filter += AccentGroupingsOnFilter; _accentGroupings.SortDescriptions.Add(new SortDescription("SortOrder", ListSortDirection.Ascending)); _selectedAccent = (from a in _accents where a.Name == _settings.Accent select a).FirstOrDefault(); if (_selectedAccent == null) { SelectedAccent = CurrentAccent; } SelectedAccent.Apply(); ApplyCommand = new DelegateCommand(Apply, CanExecuteApply); CancelCommand = new DelegateCommand(Cancel, CanExecuteCancel); }
/// <summary> /// Speichert die vorgenommenen Einstellungen /// </summary> private void SaveSettings() { ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings; Windows.Storage.ApplicationDataCompositeValue composite = new ApplicationDataCompositeValue(); composite["Theme"] = SelectedTheme.ToString(); roamingSettings.Values["ApplicationSettings"] = composite; }
private void UpdateThemesList() { var dir = FilesStorage.Instance.GetDirectory("Themes"); var files = FileUtils.GetFilesSafe(dir, "*.xaml"); Themes.ReplaceEverythingBy(files.Any() ? BuiltInThemes.OfType <object>().Append(new Separator()).Concat(files.Select(x => new ThemeLink(x))) : BuiltInThemes); SelectedTheme?.Update(); }
public ThemeSelectSettingItemViewModel(string label, ApplicationSettings applicationSettings, IEventAggregator eventAggregator) { Label = label; _eventAggregator = eventAggregator; SelectedTheme = applicationSettings.ToReactivePropertyAsSynchronized(x => x.Theme); _themeChangedSubscriber = SelectedTheme.Subscribe(theme => { _eventAggregator.GetEvent <ThemeChangeRequestEvent>().Publish(theme); }); }
private void LoadedAction() { var preferences = PreferencesService.GetPreferences(); Delimiter.Value = preferences.Delimiter; var count = 1; foreach (var modifierKey in ModifierKey1.Where(x => x != ModifierKeys.None && preferences.ShowHideShortcut.ModifierKeys.HasFlag(x))) { if (count == 1) { var modifierKeyIndex = ModifierKey1.IndexOf(modifierKey); SelectedModifierKey1.Value = modifierKeyIndex < 0 ? ModifierKeys.None : ModifierKey1[modifierKeyIndex]; } if (count == 2) { var modifierKeyIndex = ModifierKey2.IndexOf(modifierKey); SelectedModifierKey2.Value = modifierKeyIndex < 0 ? ModifierKeys.None : ModifierKey2[modifierKeyIndex]; break; } count++; } var keyIndex = Keys.IndexOf(preferences.ShowHideShortcut.Key); SelectedKey.Value = keyIndex < 0 ? Key.None : Keys[keyIndex]; Delimiter.Subscribe(_ => ClearMessage()); SelectedModifierKey1.Subscribe(_ => ClearMessage()); SelectedModifierKey2.Subscribe(_ => ClearMessage()); SelectedKey.Subscribe(_ => ClearMessage()); SelectedTheme.Subscribe(_ => ClearMessage()); AutoLaunch.Subscribe(_ => ClearMessage()); var themeIndex = ThemeNames.IndexOf(preferences.ThemeName); SelectedTheme.Value = themeIndex < 0 ? AppTheme.GenerateDefault().ThemeName : ThemeNames[themeIndex]; AutoLaunch.Value = preferences.AutoLaunch; }
private void Apply() { _isApplying = true; RaisePropertyChanged("CanCancel"); RaisePropertyChanged("CanApply"); ApplyCommand.RaiseCanExecuteChanged(); if (!Equals(SelectedAccent, CurrentAccent)) { SelectedAccent.Apply(); } if (!Equals(SelectedTheme, CurrentTheme)) { SelectedTheme.Apply(); } _settings.Save(); _isApplying = false; RaisePropertyChanged("CanCancel"); RaisePropertyChanged("CanApply"); ApplyCommand.RaiseCanExecuteChanged(); }
static Grid MainContent(Visuals visuals, SelectedTheme[] availableThemes, SelectedTheme selectedTheme, bool isDarkTheme) => new Grid
private void OnThemeObsolete(object sender, EventArgs e) { SelectedTheme?.Apply(); }
public SimpleCalendar SetupTheme() { SelectedTheme.SetTheme(); return(this); }