コード例 #1
0
        /// <summary>
        /// Default constructor taking care of initialization
        /// </summary>
        public MetroWindowManager(
            IEnumerable <IConfigureWindowViews> configureWindows,
            IEnumerable <IConfigureDialogViews> configureDialogs,
            IResourceProvider resourceProvider,
            IUiConfiguration uiConfiguration = null
            ) : base(configureWindows, configureDialogs, uiConfiguration)
        {
            _resourceProvider = resourceProvider;
            foreach (var style in Styles)
            {
                AddMahappsStyle(style);
            }
            // Just in case, remove them before adding
            RemoveMahappsStyle($"Accents/{Theme}");
            RemoveMahappsStyle($"Accents/{ThemeAccent}");

            if (ThemeAccent == ThemeAccents.Default)
            {
                ThemeAccent = ThemeAccents.Blue;
            }
            if (Theme == Themes.Default)
            {
                Theme = Themes.BaseLight;
            }

            AddMahappsStyle($"Accents/{ThemeAccent}");
            AddMahappsStyle($"Accents/{Theme}");
        }
コード例 #2
0
        public void LoadData()
        {
            ThemeAccents = ThemeManager.Accents
                           .Select(a => new Utils.Theme {
                ColorName = a.Name, BrushTheme = a.Resources["AccentColorBrush"] as Brush
            })
                           .ToList();
            AppThemes = ThemeManager.AppThemes
                        .Select(a => new Utils.Theme {
                ColorName = a.Name, BrushBorder = a.Resources["BlackColorBrush"] as Brush, BrushTheme = a.Resources["WhiteColorBrush"] as Brush
            })
                        .ToList();
            SelectedThemeColor = ThemeAccents.SingleOrDefault(c => c.ColorName == Settings.Default.ThemeColor);
            SelectedThemeStyle = AppThemes.SingleOrDefault(c => c.ColorName == Settings.Default.ThemeStyle);


            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ThemeAccents)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(AppThemes)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SelectedThemeColor)));
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(SelectedThemeStyle)));
        }
コード例 #3
0
        private void ChangeTheme(ThemeAccents themeAccent)
        {
            if (!Application.Current.Dispatcher.CheckAccess())
            {
                Application.Current.Dispatcher.BeginInvoke(new Action <ThemeAccents>(this.ChangeTheme), themeAccent);
            }
            else
            {
                var newAccent = ThemeManager.GetAccent(themeAccent.ToString());
                if (newAccent != null)
                {
                    var theme = ThemeManager.DetectAppStyle(Application.Current);
                    ThemeManager.ChangeAppStyle(Application.Current, newAccent, theme.Item1);

                    this.Info($"Change theme: NewTheme: {newAccent.Name} Theme changed.");
                }
                else
                {
                    this.Info($"Change theme: Theme not found: {themeAccent}.");
                }
            }
        }
コード例 #4
0
 public static void UpdateTheme(ThemeAccents accent, ThemeBaseColors baseColor)
 {
     ThemeManager.ChangeAppStyle(Application.Current,
                                 ThemeManager.GetAccent(accent.ToString()),
                                 ThemeManager.GetAppTheme(baseColor.ToString()));
 }
コード例 #5
0
 /// <summary>
 ///     Change the current theme accent
 /// </summary>
 /// <param name="themeAccent">ThemeAccents</param>
 public void ChangeThemeAccent(ThemeAccents themeAccent)
 {
     RemoveMahappsStyle($"Accents/{ThemeAccent}");
     ThemeAccent = themeAccent;
     AddMahappsStyle($"Accents/{ThemeAccent}");
 }