- Change in Theme loading and themes (in Progress)
7eb2a436
Dimitar Tsenev
committed
succeeded
4 changed files
App.xaml
/BExplorer/BetterExplorer/App.xaml-1+1
/BExplorer/BetterExplorer/App.xaml
Add comment 8 <ResourceDictionary.MergedDictionaries>
Add comment 9 <ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Generic.xaml" />
Add comment 10 <!--<ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Colors/BaseDark.xaml" />-->
Add comment 11 Minus   <ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Accents/Orange.xaml" />
Add comment 11 Plus   <ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Accents/Amber.xaml" />
Add comment 12 <ResourceDictionary Source="/BetterExplorer;component/Translation/Locale.bg-BG.xaml" />
Add comment 13 <ResourceDictionary Source="/BetterExplorer;component/Translation/Locale.it-IT.xaml" />
Add comment 14 <ResourceDictionary Source="/BetterExplorer;component/Translation/Locale.es-ES.xaml" />
App.xaml.cs
/BExplorer/BetterExplorer/App.xaml.cs-15+15
/BExplorer/BetterExplorer/App.xaml.cs
Add comment 174 //// loads current Ribbon color theme
Add comment 175 try {
Add comment 176 var owner = Current.MainWindow;
Add comment 177 Minus   ThemeManager.ChangeAppTheme(this,"BaseDark");
Add comment 177 Plus  
Add comment 178 //if (owner != null) {
Add comment 179 // owner.Resources.BeginInit();
Add comment 180
Add comment 193
Add comment 194 //Current.Resources.MergedDictionaries.RemoveAt(1);
Add comment 195
Add comment 196 Minus   //switch (Settings.BESettings.CurrentTheme) {
Add comment 197 Minus   // case "Blue":
Add comment 198 Minus   // case "Silver":
Add comment 199 Minus   // case "Black":
Add comment 200 Minus   // case "Green":
Add comment 201 Minus   // Current.Resources.MergedDictionaries.Insert(1, new ResourceDictionary() { Source = new Uri($"pack://application:,,,/Fluent;component/Themes/Office2010/{Settings.BESettings.CurrentTheme}.xaml") });
Add comment 202 Minus   // break;
Add comment 203 Minus   // case "Metro":
Add comment 204 Minus   // Current.Resources.MergedDictionaries.Insert(1, new ResourceDictionary() { Source = new Uri("pack://application:,,,/Fluent;component/Themes/Office2013/Generic.xaml") });
Add comment 205 Minus   // break;
Add comment 206 Minus   // default:
Add comment 207 Minus   // Current.Resources.MergedDictionaries.Insert(1, new ResourceDictionary() { Source = new Uri($"pack://application:,,,/Fluent;component/Themes/Office2010/{Settings.BESettings.CurrentTheme}.xaml") });
Add comment 208 Minus   // break;
Add comment 209 Minus   //}
Add comment 196 Plus   switch (Settings.BESettings.CurrentTheme) {
Add comment 197 Plus   case "Blue":
Add comment 198 Plus   case "Silver":
Add comment 199 Plus   case "Black":
Add comment 200 Plus   case "Green":
Add comment 201 Plus   ThemeManager.ChangeAppTheme(this, "BaseDark");
Add comment 202 Plus   break;
Add comment 203 Plus   case "Metro":
Add comment 204 Plus   ThemeManager.ChangeAppTheme(this, "BaseLight");
Add comment 205 Plus   break;
Add comment 206 Plus   default:
Add comment 207 Plus   ThemeManager.ChangeAppTheme(this, "BaseLight");
Add comment 208 Plus   break;
Add comment 209 Plus   }
Add comment 210
Add comment 211 //Current.Resources.EndInit();
Add comment 212 }
BetterExplorer.ruleset
/BExplorer/BetterExplorer/BetterExplorer.ruleset+3
/BExplorer/BetterExplorer/BetterExplorer.ruleset
Add comment 16 <Rule Id="IDE0002" Action="None" />
Add comment 17 <Rule Id="IDE0003" Action="None" />
Add comment 18 </Rules>
Add comment 19 Plus   <Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
Add comment 20 Plus   <Rule Id="SA1118" Action="Info" />
Add comment 21 Plus   </Rules>
Add comment 19 22 </RuleSet>
MainWindow.xaml.cs
/BExplorer/BetterExplorer/MainWindow.xaml.cs-27+18
/BExplorer/BetterExplorer/MainWindow.xaml.cs
Add comment 1838
Add comment 1839 #region Change Ribbon Color (Theme)
Add comment 1840
Add comment 1841 Minus   public void ChangeRibbonTheme(string ThemeName, bool IsMetro = false) {
Add comment 1842 Minus   this.Dispatcher.BeginInvoke(IsMetro ? DispatcherPriority.ApplicationIdle : DispatcherPriority.Render, (ThreadStart)(() => {
Add comment 1843 Minus   var owner = Window.GetWindow(this);
Add comment 1844 Minus   Application.Current.Resources.BeginInit();
Add comment 1845 Minus   Application.Current.Resources.MergedDictionaries.RemoveAt(1);
Add comment 1846 Minus  
Add comment 1847 Minus   if (IsMetro)
Add comment 1848 Minus   Application.Current.Resources.MergedDictionaries.Insert(1, new ResourceDictionary() { Source = new Uri("pack://application:,,,/Fluent;component/Themes/Office2013/Generic.xaml") });
Add comment 1849 Minus   else
Add comment 1850 Minus   Application.Current.Resources.MergedDictionaries.Insert(1, new ResourceDictionary() { Source = new Uri($"pack://application:,,,/Fluent;component/Themes/Office2010/{ThemeName}.xaml") });
Add comment 1851 Minus  
Add comment 1852 Minus   Application.Current.Resources.EndInit();
Add comment 1853 Minus  
Add comment 1854 Minus   if (owner is RibbonWindow) {
Add comment 1855 Minus   owner.Style = null;
Add comment 1856 Minus   owner.Style = owner.FindResource("RibbonWindowStyle") as Style;
Add comment 1857 Minus   owner.Style = null;
Add comment 1858 Minus  
Add comment 1859 Minus   // Resize Window to work around alignment issues caused by theme change
Add comment 1860 Minus   ++owner.Width;
Add comment 1861 Minus   --owner.Width;
Add comment 1841 Plus   public void ChangeRibbonTheme(string themeName, bool IsMetro = false) => this.Dispatcher.BeginInvoke(DispatcherPriority.Render, (ThreadStart)(() => {
Add comment 1842 Plus   switch (themeName) {
Add comment 1843 Plus   case "Blue":
Add comment 1844 Plus   case "Silver":
Add comment 1845 Plus   case "Black":
Add comment 1846 Plus   case "Green":
Add comment 1847 Plus   ThemeManager.ChangeAppTheme(Application.Current, "BaseDark");
Add comment 1848 Plus   break;
Add comment 1849 Plus   case "Metro":
Add comment 1850 Plus   ThemeManager.ChangeAppTheme(Application.Current, "BaseLight");
Add comment 1851 Plus   break;
Add comment 1852 Plus   default:
Add comment 1853 Plus   ThemeManager.ChangeAppTheme(Application.Current, "BaseLight");
Add comment 1854 Plus   break;
Add comment 1862 1855 }
Add comment 1863 Minus  
Add comment 1864 Minus   Settings.BESettings.CurrentTheme = ThemeName;
Add comment 1856 Plus   Settings.BESettings.CurrentTheme = themeName;
Add comment 1865 1857 Settings.BESettings.SaveSettings();
Add comment 1866 1858 }));
Add comment 1867 Minus   }
Add comment 1868 1859
Add comment 1869 1860 private void btnSilver_Click(object sender, RoutedEventArgs e) {
Add comment 1870 1861 this.ChangeRibbonTheme("Silver");
Add comment 3737 3728 case "Silver":
Add comment 3738 3729 case "Black":
Add comment 3739 3730 case "Green":
Add comment 3740 Minus   this.ChangeRibbonTheme(Settings.BESettings.CurrentTheme);
Add comment 3731 Plus   ThemeManager.ChangeAppTheme(Application.Current, "BaseDark");
Add comment 3741 3732 break;
Add comment 3742 3733 case "Metro":
Add comment 3743 Minus   //ChangeRibbonTheme(Color, true);
Add comment 3734 Plus   ThemeManager.ChangeAppTheme(Application.Current, "BaseLight");
Add comment 3744 3735 //Do nothing since Metro should be already loaded in App.Startup
Add comment 3745 3736 break;
Add comment 3746 3737 default:
Add comment 3747 Minus   this.ChangeRibbonTheme("Blue");
Add comment 3738 Plus   ThemeManager.ChangeAppTheme(Application.Current, "BaseLight");
Add comment 3748 3739 break;
Add comment 3749 3740 }
Add comment 3750 3741 } catch (Exception ex) {