示例#1
0
        private VisualTheme GetThemeFromId(string id)
        {
            var comparer = StringComparer.OrdinalIgnoreCase;
            var match    = ThemesView.Select(x => x as VisualTheme).FirstOrDefault(x => comparer.Equals(x.ThemeId, id));

            return(match);
        }
示例#2
0
 private void SelectFromId(string id)
 {
     if (!string.IsNullOrWhiteSpace(id))
     {
         var match = GetThemeFromId(id);
         if (match != null)
         {
             ThemesView.MoveCurrentTo(match);
         }
     }
 }
示例#3
0
        public VisualThemeSelector()
        {
            _themes = new List <VisualTheme>();

            Fill();

            var source = new CollectionViewSource()
            {
                Source = _themes
            };

            ThemesView = source.View;
            ThemesView.CurrentChanged += ThemesView_CurrentChanged;

            //
            SystemUI = new UISettings();
            SystemUI.ColorValuesChanged += SystemThemeChanged;

            //Select here from settings:
            ThemesView.MoveCurrentToFirst();
            //
        }
示例#4
0
        public VisualThemeSelector(
            IServiceProvider serviceProvider
            , WindowsSettingsViewModel settingsViewModel
            , ResourceDictionary resources)
        {
            ServiceProvider = serviceProvider;
            Resources       = resources;

            _settingsViewModel = settingsViewModel;
            _settingsViewModel.PropertyChanged += SettingsViewModelOnPropertyChanged;

            _themes = new List <VisualTheme>();

            Fill();

            var source = new CollectionViewSource()
            {
                Source = _themes
            };

            ThemesView = source.View;
            ThemesView.CurrentChanged += ThemesView_CurrentChanged;

            //
            SystemUI = new UISettings();
            SystemUI.ColorValuesChanged += SystemThemeChanged;

            //Select here from settings:
            if (string.IsNullOrWhiteSpace(_settingsViewModel.CustomThemeId))
            {
                ThemesView.MoveCurrentToFirst();
            }
            else
            {
                SelectFromId(_settingsViewModel.CustomThemeId);
            }
            //
        }