none
How to retrieve VS 2017/ 2019 code syntax colours RRS feed

  • Question

  • I am building an advanced editor for VS 2017 / 2019 for a solution I'm creating.  I want total control over the editor itself, including embedding it inside of other WPF controls as part of an overall UX experience.

    As such, the editor has code styling, as in, all elements in a .cs file (namespace, using statements, comments, public private abstract etc., braces, loops, what have you) have specific colours which should be applied.

    One of the things which is important is to maintain the same colours as defined by the user / theme the user has chosen.

    Now, for all the environment colours (that is, all aspects of VS which are not the contents of the editor window), these are easily obtained via the method

    VSColorTheme.GetThemedColor(themeResourceKey);

    Using the predefined themeResourceKeys as defined in

    Microsoft.VisualStudio.PlatformUI.EnvironmentColors

    So, for example, to retrieve the background color key for the tool window background, you call the following

    VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowBackgroundColorKey);

    What I am after is the keys of the colors being used by VS to color class names, comments, line number, privates, publics, statics, etc, all colors used in the editor. With these color keys, I'd like to then use these code keys to call a VS extensibility class or method to retrieve the actual colours being used.

    Does anyone have any knowledge on how the editor is retrieving these actual color keys, and how I can use these to retrieve the currently set color?

    Thanks


    Sunday, May 12, 2019 1:35 AM

All replies

  • Hi friend,

    Welcome to MSDN forum.

    >>What I am after is the keys of the colors being used by VS to color class names, comments, line number, privates, publics, statics, etc, all colors used in the editor.

    Maybe this blog helps.

    >>Does anyone have any knowledge on how the editor is retrieving these actual color keys, and how I can use these to retrieve the currently set color?

    Sorry that not familiar with color topic. But I find these item-color are set by Tools=>Options=>Environment=>Fonts and Colors. See this.

    Not sure if we can access this setting to control your color settings. Hope it makes some help.

    Best Regards

    Lance


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, May 14, 2019 11:03 AM