@@ -555,37 +555,41 @@ private void InitializeTheme()
555555 themeMenuItem . DropDownItems . Add ( _autoThemeMenuItem ) ;
556556 }
557557
558+ var settingsTheme = _settings . GetValue ( "theme" , "auto" ) ;
558559 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 ) ;
560561 if ( setTheme != null )
561562 {
562563 Theme . Current = setTheme ;
563- Theme . Current . Apply ( this ) ;
564564 }
565565
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 )
567569 {
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 ) ;
580572 }
581573
582- AddThemeMenuItems ( allThemes . Where ( t => t is not CustomTheme ) ) ;
583- themeMenuItem . DropDownItems . Add ( "-" ) ; //separator
584- AddThemeMenuItems ( allThemes . Where ( t => t is CustomTheme ) ) ;
585-
586574 if ( setTheme == null && themeMenuItem . DropDownItems . Count > 0 )
587- {
588575 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+ }
589593 }
590594 }
591595
0 commit comments