Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the Visual Studio color scheme from a VSPackage

Somebody know how can I get the color scheme programatically using a VSPackage in C#?

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

Thanks in advance.

like image 210
Daniel Peñalba Avatar asked Jun 11 '12 14:06

Daniel Peñalba


People also ask

How do I get more color themes in Visual Studio?

On the menu bar, select Tools > Options. In the options list, select Environment > General. In the Color theme list, choose between the default Dark theme, the Blue theme, the Blue (Extra Contrast) theme, and the Light theme. Or, choose the Use system setting option to select the theme that Windows uses.

What is Vspackage?

VSPackages are software modules that extend the Visual Studio integrated development environment (IDE) by providing UI elements, services, projects, editors, and designers.


1 Answers

There are two ways, using 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;
    }
like image 103
Daniel Peñalba Avatar answered Sep 20 '22 17:09

Daniel Peñalba