问题
In my editor extension I use custom classification formats for keywords, identifiers and so on. Of course, there are default formats I could use, because then colors (used by syntax highlighting) will be changed in accordance to the selected theme.
Since my custom editor also needs additional classification types (for instance a punctuation type), colors for those types won´t change when the user configures another theme (by switching from Dark
to Blue
theme, for instance). I would like to know how I can proffer theme-specific formats.
回答1:
The best approach I have found to support multiple colour schemes (themes) is to hook into the ThemeChanged event and then update your classification types accordingly. Where possible I update my custom colours from predefined VS formats that are similar to my custom formats (e.g. use the standard VS Keyword colours to set the defaults on my custom keyword format), since I know these colours will likely be maintained by any custom themes the user has applied.
The Visual F# Power Tools use this approach, which I discovered from this answer.
来源:https://stackoverflow.com/questions/22453969/how-to-define-classification-formats-for-each-theme