
I am trying to use the C# vssettings dark theme provided with the sample projects by applying it to a custom HighlightingStyleRegistry. The caveat is our application uses other custom language definitions and we also allow changing the theme without restarting the app.
The problem I am facing is after setting SyntaxEditor.HighlightingStyleRegistry with the custom C# HighlightingStyleRegistry object, all highlighting is removed and I just get black text on a white background.
Here is the abbreviated code I am using to set the C# dark theme:
new DisplayItemClassificationTypeProvider().RegisterAll();
var registry = new HighlightingStyleRegistry();
// copy types and styles so the ImportHighlightingStyles works
var classificationTypes = AmbientHighlightingStyleRegistry.Instance.ClassificationTypes.ToArray();
var highlightingStyles = AmbientHighlightingStyleRegistry.Instance.HighlightingStyles.ToArray();
for (var i = 0; i < classificationTypes.Length; i++)
{
var classificationType = classificationTypes[i];
var highlightingStyle = highlightingStyles[i];
var newClassificationType = new ClassificationType(classificationType.Key, classificationType.Description);
var newHighlightStyle = new HighlightingStyle(highlightingStyle.Foreground, highlightingStyle.Background, highlightingStyle.Bold, highlightingStyle.Italic, highlightingStyle.UnderlineKind, highlightingStyle.BackgroundSpansVirtualSpace);
registry.Register(newClassificationType, newHighlightStyle);
}
using (var stream = new MemoryStream(Properties.Resources.DarkTheme))
registry.ImportHighlightingStyles(stream);
syntaxEditor.HighlightingStyleRegistry = registry;
This is called while the SyntaxEditor is showing. I don't really want to use the AmbientHighlightingStyleRegistry.Instance as other SyntaxEditor's will be using other dark theme HighlightingStyleRegistry's. If I set SyntaxEditor.HighlightingStyleRegistry back to null (Light theme), then the highlighting works as expected.
Is there a way to import the vssettings file into a custom HighlightingStyleRegistry?
Do I need to copy the highlighting types and styles from the AmbientHighlightingStyleRegistry instance?