Skip to content

Commit

Permalink
Visual Studio Extension - dark theme support
Browse files Browse the repository at this point in the history
Resolves #55
  • Loading branch information
tomasherceg authored and tomasherceg committed Apr 14, 2015
1 parent fda492d commit 2a6ca2c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Redwood.VS2015Extension/Redwood.VS2015Extension.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<HintPath>..\packages\Microsoft.CodeAnalysis.Workspaces.Common.1.0.0-rc1\lib\net45\Microsoft.CodeAnalysis.Workspaces.Desktop.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.VisualStudio.CoreUtility, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VSSDK\VisualStudioIntegration\Common\Assemblies\v4.0\Microsoft.VisualStudio.CoreUtility.dll</HintPath>
Expand Down Expand Up @@ -184,6 +185,7 @@
<HintPath>..\packages\Microsoft.Composition.1.0.27\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Reflection.Metadata, Version=1.0.18.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reflection.Metadata.1.0.18-beta\lib\portable-net45+win8\System.Reflection.Metadata.dll</HintPath>
<Private>True</Private>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ public class VisualStudioThemeManager

public static VisualStudioTheme GetCurrentTheme()
{
string themeId = GetThemeId();
if (string.IsNullOrWhiteSpace(themeId) == false)
string themeId = GetThemeIdFromRegistry();
if (string.IsNullOrWhiteSpace(themeId))
{
return GetThemeFromColorSettings();
}
else
{
VisualStudioTheme theme;
if (Themes.TryGetValue(themeId, out theme))
{
Expand All @@ -30,7 +34,24 @@ public static VisualStudioTheme GetCurrentTheme()
return VisualStudioTheme.Unknown;
}

public static string GetThemeId()
private static VisualStudioTheme GetThemeFromColorSettings()
{
try
{
var background = CompletionHelper.DTE.Properties["FontsAndColors", "TextEditor"].Item("FontsAndColorsItems").Object.Item("Plain Text").Background;
var plainTextBackgroundColor = System.Drawing.ColorTranslator.FromOle((int)background);
if (plainTextBackgroundColor.R < 100)
{
return VisualStudioTheme.Dark;
}
}
catch (Exception ex)
{
}
return VisualStudioTheme.Unknown;
}

public static string GetThemeIdFromRegistry()
{
const string CategoryName = "General";
const string ThemePropertyName = "CurrentTheme";
Expand Down

0 comments on commit 2a6ca2c

Please sign in to comment.