Exemple #1
0
        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);
        }
        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();
        }
Exemple #4
0
 private void OnThemeObsolete(object sender, EventArgs e)
 {
     SelectedTheme?.Apply();
 }