
So, for future reference, this is how I was able to accomplish it. Not terribly difficult, but I am still scratching my head as to why I had to instantiate the HighlightingStyleRegistry. I was assuming that I could pull the ClassificationTypes from my LangDef, but the HSR was always null. By registering the ClassificationType in the HSR, the highlighting works as expected. I traversed the object and could find no evidence of my ClassificationTypes that were already defined in my LangDef file.
Am I missing something there? Is this just a case of me binding to the WPF with the .Register command?
Thanks for the prompt replies, it was very helpful.
-TPP
SyntaxLanguageDefinitionSerializer serializer = new SyntaxLanguageDefinitionSerializer();
string path = @"C:\Oasis\OCL.langdef";
ISyntaxLanguage language = serializer.LoadFromFile(path);
syntaxEditor.Document.Language = language;
BrushConverter bc = new BrushConverter();
// Create a custom Console Window registry
IHighlightingStyleRegistry consoleWindowRegistry = new HighlightingStyleRegistry();
consoleWindowRegistry.Description = "OCL Window";
syntaxEditor.HighlightingStyleRegistry = consoleWindowRegistry;
consoleWindowRegistry.Register(new ClassificationType("Comment"), new HighlightingStyle((Brush)bc.ConvertFrom("#FF008000"),(Brush)bc.ConvertFrom("#FFF7E746")));
My LangDef file looks like this:
<LanguageProject LanguageKey="OCL" LanguageDescription="OCL" OutputLanguageDefinition="False" OutputLanguageKey="CSharp" OutputNamespaceName="ActiproSoftware.Text.Languages.OCL" OutputPath="C:\.." Creator="" Copyright="...">
<!-- Classification types -->
<LanguageProject.ClassificationTypes>
<ClassificationType Key="Comment" DefaultStyle="#FF008000" />
...
</LanguageProject.ClassificationTypes>