@@ -555,37 +555,41 @@ private void InitializeTheme()
555
555
themeMenuItem . DropDownItems . Add ( _autoThemeMenuItem ) ;
556
556
}
557
557
558
+ var settingsTheme = _settings . GetValue ( "theme" , "auto" ) ;
558
559
var allThemes = CustomTheme . GetAllThemes ( "themes" , "OpenHardwareMonitor.Resources.themes" ) . OrderBy ( x => x . DisplayName ) . ToList ( ) ;
559
- Theme setTheme = allThemes . FirstOrDefault ( theme => _settings . GetValue ( "theme" , "auto" ) == theme . Id ) ;
560
+ var setTheme = allThemes . FirstOrDefault ( theme => settingsTheme == theme . Id ) ;
560
561
if ( setTheme != null )
561
562
{
562
563
Theme . Current = setTheme ;
563
- Theme . Current . Apply ( this ) ;
564
564
}
565
565
566
- void AddThemeMenuItems ( IEnumerable < Theme > themes )
566
+ AddThemeMenuItems ( allThemes . Where ( t => t is not CustomTheme ) ) ;
567
+ var customThemes = allThemes . Where ( t => t is CustomTheme ) . ToList ( ) ;
568
+ if ( customThemes . Count > 0 )
567
569
{
568
- foreach ( Theme theme in themes )
569
- {
570
- var item = new ToolStripRadioButtonMenuItem ( theme . DisplayName ) ;
571
- item . Tag = theme ;
572
- item . Click += OnThemeMenuItemClick ;
573
- themeMenuItem . DropDownItems . Add ( item ) ;
574
-
575
- if ( Theme . Current != null && Theme . Current . Id == theme . Id )
576
- {
577
- item . Checked = true ;
578
- }
579
- }
570
+ themeMenuItem . DropDownItems . Add ( "-" ) ;
571
+ AddThemeMenuItems ( customThemes ) ;
580
572
}
581
573
582
- AddThemeMenuItems ( allThemes . Where ( t => t is not CustomTheme ) ) ;
583
- themeMenuItem . DropDownItems . Add ( "-" ) ; //separator
584
- AddThemeMenuItems ( allThemes . Where ( t => t is CustomTheme ) ) ;
585
-
586
574
if ( setTheme == null && themeMenuItem . DropDownItems . Count > 0 )
587
- {
588
575
themeMenuItem . DropDownItems [ 0 ] . PerformClick ( ) ;
576
+
577
+ Theme . Current . Apply ( this ) ;
578
+ }
579
+
580
+ private void AddThemeMenuItems ( IEnumerable < Theme > themes )
581
+ {
582
+ foreach ( Theme theme in themes )
583
+ {
584
+ var item = new ToolStripRadioButtonMenuItem ( theme . DisplayName ) ;
585
+ item . Tag = theme ;
586
+ item . Click += OnThemeMenuItemClick ;
587
+ themeMenuItem . DropDownItems . Add ( item ) ;
588
+
589
+ if ( Theme . Current != null && Theme . Current . Id == theme . Id )
590
+ {
591
+ item . Checked = true ;
592
+ }
589
593
}
590
594
}
591
595
0 commit comments