Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AppearanceCommands"/> class.
        /// </summary>
        public AppearanceCommands()
        {
            var manager = AppearanceManager.GetForCurrentView();

            this.SetAccentColorCommand = new RelayCommand(o => AppearanceManager.AccentColor = this.converter.ConvertBack(o));
            this.SetDarkThemeCommand   = new RelayCommand(o => manager.Theme = ApplicationTheme.Dark, o => manager.Theme == ApplicationTheme.Light);
            this.SetLightThemeCommand  = new RelayCommand(o => manager.Theme = ApplicationTheme.Light, o => manager.Theme == ApplicationTheme.Dark);
            this.ToggleThemeCommand    = new RelayCommand(o => manager.Theme = manager.Theme == ApplicationTheme.Dark ? ApplicationTheme.Light : ApplicationTheme.Dark);

            manager.RegisterEventSink(this);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SettingsViewModel"/>.
        /// </summary>
        public SettingsViewModel()
        {
            this.Brushes = AccentColors.Windows10.Select(c => new SolidColorBrush(c)).ToImmutableList();
            this.Themes  = ImmutableList.Create(
                new DisplayableTheme("Dark", ApplicationTheme.Dark),
                new DisplayableTheme("Light", ApplicationTheme.Light));

            // ensure viewmodel state reflects actual appearance
            var manager = AppearanceManager.GetForCurrentView();

            this.selectedTheme = this.Themes.FirstOrDefault(t => t.Theme == manager.Theme);

            if (AppearanceManager.AccentColor == null)
            {
                this.useSystemAccentColor = true;
            }
            else
            {
                this.selectedBrush = this.Brushes.FirstOrDefault(b => b.Color == AppearanceManager.AccentColor);
            }
        }
Пример #3
0
        private void SyncSelectedTheme()
        {
            var manager = AppearanceManager.GetForCurrentView();

            this.SelectedTheme = this.Themes.FirstOrDefault(t => t.Theme == manager.Theme);
        }