This repository was archived by the owner on Jun 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
src/GitHub.VisualStudio.UI Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 11using Microsoft . VisualStudio . PlatformUI ;
22using System ;
3+ using System . Windows ;
34using System . Windows . Media ;
45
56namespace GitHub . VisualStudio . Helpers
@@ -34,25 +35,22 @@ public static Color ToColor(this System.Drawing.Color color)
3435
3536 public static string DetectTheme ( )
3637 {
37- try
38+ if ( Application . Current ? . TryFindResource ( EnvironmentColors . AccentMediumColorKey ) is Color cc )
3839 {
39- var color = VSColorTheme . GetThemedColor ( EnvironmentColors . AccentMediumColorKey ) ;
40- var cc = color . ToColor ( ) ;
4140 if ( cc == AccentMediumBlueTheme )
4241 return "Blue" ;
4342 if ( cc == AccentMediumLightTheme )
4443 return "Light" ;
4544 if ( cc == AccentMediumDarkTheme )
4645 return "Dark" ;
46+ var color = System . Drawing . Color . FromArgb ( cc . A , cc . R , cc . R , cc . B ) ;
4747 var brightness = color . GetBrightness ( ) ;
4848 var dark = brightness < 0.5f ;
4949 return dark ? "Dark" : "Light" ;
5050 }
51- // this throws in design time and when running outside of VS
52- catch ( ArgumentNullException )
53- {
54- return "Dark" ;
55- }
51+
52+ // When Visual Studio resources aren't active
53+ return "Dark" ;
5654 }
5755 }
5856}
You can’t perform that action at this time.
0 commit comments