@@ -32,12 +32,15 @@ public GitHubInvitationSection(IConnectionManager cm, Lazy<IVisualStudioBrowser>
3232 Name = "GitHub" ;
3333 Provider = "GitHub, Inc." ;
3434 Description = Resources . BlurbText ;
35- Icon = GetDrawingForIcon ( GetBrushForIcon ( ) ) ;
35+ OnThemeChanged ( ) ;
36+ VSColorTheme . ThemeChanged += _ =>
37+ {
38+ OnThemeChanged ( ) ;
39+ } ;
3640
3741 IsVisible = cm . Connections . Count == 0 ;
3842
3943 cm . Connections . CollectionChanged += ( s , e ) => IsVisible = cm . Connections . Count == 0 ;
40- VSColorTheme . ThemeChanged += OnThemeChanged ;
4144 }
4245
4346 public override void Connect ( )
@@ -57,22 +60,20 @@ void StartFlow(UIControllerFlow controllerFlow)
5760 uiProvider . RunUI ( controllerFlow , null ) ;
5861 }
5962
60- void OnThemeChanged ( ThemeChangedEventArgs e )
63+ void OnThemeChanged ( )
6164 {
62- Icon = GetDrawingForIcon ( GetBrushForIcon ( ) ) ;
63- }
65+ try
66+ {
67+ var color = VSColorTheme . GetThemedColor ( EnvironmentColors . ToolWindowTextColorKey ) ;
68+ var brightness = color . GetBrightness ( ) ;
69+ var dark = brightness > 0.5f ;
6470
65- static Brush GetBrushForIcon ( )
66- {
67- var brush = Application . Current . TryFindResource ( HeaderColors . DefaultTextBrushKey ) as Brush ;
68- if ( brush == null )
69- brush = Brushes . Black ;
70- return brush ;
71- }
72-
73- static DrawingBrush GetDrawingForIcon ( Brush color )
74- {
75- return SharedResources . GetDrawingForIcon ( Octicon . mark_github , color ) ;
71+ Icon = SharedResources . GetDrawingForIcon ( Octicon . mark_github , dark ? Helpers . Colors . DarkThemeNavigationItem : Helpers . Colors . LightThemeNavigationItem , dark ? "dark" : "light" ) ;
72+ }
73+ catch ( ArgumentNullException )
74+ {
75+ // This throws in the unit test runner.
76+ }
7677 }
7778 }
7879}
0 commit comments