예제 #1
0
        public SettingsWindowViewModel() : base()
        {
            AccentColors = ThemeManager.Current.Themes
                           .GroupBy(x => x.ColorScheme)
                           .OrderBy(a => a.Key)
                           .Select(a => new AccentColorMenuData {
                Name = a.Key, ColorBrush = a.First().ShowcaseBrush
            })
                           .ToList();
            AccentColor = AccentColors.First(x => x.Name == App.Theme.ColorScheme);
            AppThemes   = ThemeManager.Current.Themes
                          .GroupBy(x => x.BaseColorScheme)
                          .Select(x => x.First())
                          .Select(a => new AppThemeMenuData {
                Name = a.BaseColorScheme, BorderColorBrush = a.Resources["MahApps.Brushes.ThemeForeground"] as Brush, ColorBrush = a.Resources["MahApps.Brushes.ThemeBackground"] as Brush
            })
                          .ToList();
            AppTheme = AppThemes.First(x => x.Name == App.Theme.BaseColorScheme);
            var resources = App.Theme.LibraryThemes.First(x => x.Origin == "MahApps.Metro").Resources.MergedDictionaries.First();

            Colors = typeof(Colors).GetProperties(BindingFlags.Public | BindingFlags.Static)
                     .Where(x => x.Name != "Transparent")
                     .Select(x => new AccentColorMenuData {
                Name = x.Name, ColorBrush = new SolidColorBrush((Color)x.GetValue(null))
            })
                     .ToList();
        }
예제 #2
0
        public void Apply(ApplicationDesign design)
        {
            try
            {
                design.AccentColor.ApplyTheme();
            }
            catch (Exception)
            {
                design.AccentColor = AccentColors.First(x => x.Name == "Blue");
                design.AccentColor.ApplyTheme();
            }

            try
            {
                design.AppTheme.ApplyTheme();
            }
            catch (Exception)
            {
                design.AppTheme = AppThemes.First();
                design.AppTheme.ApplyTheme();
            }

            if (design.AudioVisualisation != null)
            {
                design.AudioVisualisation.AudioVisualisationPlugin.Refresh();
            }
        }
예제 #3
0
    /// <summary>
    /// Initializes a new instance of the <see cref="SettingsViewModel"/> class.
    /// </summary>
    /// <param name="logger">Logger dependency.</param>
    /// <param name="localization">Localization provider dependency.</param>
    /// <param name="options">Surrent settings.</param>
    /// <param name="settingsService">Settings service dependency.</param>
    public SettingsViewModel(ILogger logger,
                             ILocalization localization,
                             AppSettings options,
                             SettingsService settingsService)
    {
        CultureSelectionChangedCommand = new DelegateCommand(ChangeCulture);
        this.logger          = logger;
        this.localization    = localization;
        this.options         = options;
        this.settingsService = settingsService;

        AppThemes = ThemeManager.Current.Themes
                    .GroupBy(x => x.BaseColorScheme)
                    .Select(x => x.First())
                    .ToList();

        ColorThemes = ThemeManager.Current.ColorSchemes.OrderBy(x => x).ToList();

        Theme?currentTheme = ThemeManager.Current.DetectTheme();

        if (currentTheme != null)
        {
            SelectedAppTheme = AppThemes.First(x => x.BaseColorScheme == currentTheme.BaseColorScheme);
            SelectedColor    = ColorThemes.First(x => x == currentTheme.ColorScheme);
        }

        ShowLastWeekSuggestion = options.ShowLastWeekSuggestion;
    }
예제 #4
0
        public static void ChangeTheme(ResourceDictionary resources, Accent newAccent, Theme newTheme)
        {
            if (resources == null)
            {
                throw new ArgumentNullException("resources");
            }

            AppTheme appTheme = AppThemes.First(x => x.Name == reverseCompatibilityThemeMapping[newTheme]);

            ChangeAppStyle(resources, newAccent, appTheme);
        }
예제 #5
0
        public static void ChangeTheme(Window window, Accent newAccent, Theme newTheme)
        {
            if (window == null)
            {
                throw new ArgumentNullException("window");
            }

            var      oldTheme    = DetectTheme(window);
            AppTheme oldAppTheme = AppThemes.First(x => x.Name == reverseCompatibilityThemeMapping[oldTheme.Item1]);
            AppTheme newAppTheme = AppThemes.First(x => x.Name == reverseCompatibilityThemeMapping[newTheme]);

            ChangeAppStyle(window.Resources, Tuple.Create(oldAppTheme, oldTheme.Item2), newAccent, newAppTheme);
        }