Get Visual Studio Color Scheme from VSPackage

Does anyone know how I can get the color scheme programmatically using VSPackage in C #?

I know that I can use IVsUIShell5.GetThemedColor for VS2011, but I do not know how to get it from VS2005, VS2008 or VS2010.

Thanks in advance.

+7
source share
4 answers

There are two ways to use IVSShell and IVSShell2:

  private List<Color> GetColorList1() { IVsUIShell uiShell = (IVsUIShell)this.GetService(typeof(IVsUIShell)); List<Color> result = new List<Color>(); foreach (VSSYSCOLOR vsSysColor in Enum.GetValues(typeof(VSSYSCOLOR))) { uint win32Color; uiShell.GetVSSysColor(vsSysColor, out win32Color); Color color = ColorTranslator.FromWin32((int)win32Color); result.Add(color); } return result; } private List<Color> GetColorList2() { IVsUIShell2 uiShell = (IVsUIShell2)this.GetService(typeof(IVsUIShell2)); List<Color> result = new List<Color>(); foreach (__VSSYSCOLOREX vsSysColor in Enum.GetValues(typeof(__VSSYSCOLOREX))) { uint win32Color; uiShell.GetVSSysColorEx((int)vsSysColor, out win32Color); Color color = ColorTranslator.FromWin32((int)win32Color); result.Add(color); } return result; } 
+4
source

I found a solution:

 [Guid("0D915B59-2ED7-472A-9DE8-9161737EA1C5")] interface SVsColorThemeService { } 

then

 dynamic colorThemeService = _serviceProvider.GetService(typeof(SVsColorThemeService)); Guid id = colorThemeService.CurrentTheme.ThemeId; // should be one of the Microsoft.VisualStudio.Shell.KnownColorThemes 
+2
source

I realized that this is actually the answer.

What you want to get is not expanded by IVsUIShell4 and below

I would like to add that to my knowledge Visual Studio 2005-2010 does not even have topics for a single message. At least Visual Studio 2012 is changing this mechanic. You can download the settings file, but they are not topics for everyone.

Microsoft.VisualStudio.Shell.Interop does not even require numbering.

0
source

I assume that if there is no siutable API, you can always do this directly in the registry.

You can also see this link: How to access the embedded fonts and color scheme

0
source

All Articles