I would like to create a syntax shortcut in Visual Studio 2012 (and above) that supports different themes (dark, light, blue).
The Visual Studio Editor Classifier project template explains how to create your own colors in your environment using Microsoft.VisualStudio.Text.Classification.ClassificationFormatDefinition . It works great ...
... until you understand that there are different themes (and higher) in Visual Studio 2012, and you do not support them. Your cute blue color identifiers on a light theme become unreadable in a dark thematic environment.
As far as I understand, if you change your ClassificationFormatDefinition in Tools / Options / Fonts and Colors in a given topic (for example: Light), this will not affect the same ClassificationFormatDefinition in another theme (for example: Dark). Colors seem independent on various topics.
It's good. But how can I define the same ClassificationFormatDefinition name (for example, MyKeywords) that has the same name in all themes, but provides different colors for them? Exactly the same as Visual Studio’s own “Identifier”, which is black by default on the theme “Light” and the default value while on a black theme.
I know about the Microsoft.VisualStudio.PlatformUI.VSColorTheme.ThemeChanged event, which allows me to receive notifications when color themes change. Should I use this and somehow master the existing ClassificationFormatDefinition and assign them new colors based on a new theme? But this also raises the question: will these changed colors be saved in the environment, that is, if I restart Visual Studio, my changes will be next time in all different themes.
I did not find any attribute that would indicate which topic ClassificationFormatDefinition supports, and I did not find a lot of useful article on this subject.
Any help was appreciated.
visual-studio syntax-highlighting visual-studio-2012 vspackage visual-studio-extensions
Shakaron
source share