Пример #1
0
 public override void Apply()
 {
     try
     {
         CurrentTheme?.Remove();
         Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
         {
             Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml")
         });
         Application.Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
         {
             Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml")
         });
         ResourceDictionary resourceDictionary = new ResourceDictionary()
         {
             Source = new Uri($"pack://application:,,,/MahApps.Metro;component/Styles/Themes/{DictionaryName}.xaml")
         };
         if (resourceDictionary == null)
         {
             throw new NullReferenceException();
         }
         Application.Current.Resources.MergedDictionaries.Add(resourceDictionary);
         App.Current.Resources["AccentColor"] = new BrushConverter().ConvertFromString(AccentColor);
         if (DictionaryName[0] == 'L')
         {
             App.Current.Resources["BackgroundColor"] = new BrushConverter().ConvertFromString("#FFFFFF");
         }
         else if (DictionaryName[0] == 'D')
         {
             App.Current.Resources["BackgroundColor"] = new BrushConverter().ConvertFromString("#252525");
         }
     }
     catch { App.Logger.Log($"Can't apply {Name} theme"); }
 }