
I'm a little mystified about how the registration works; it looks like the RegisterAll() method just returns an array of IClassificationTypes, but doens't do any registering activity.
The sample has this:
// Register the default display item classification types on the ambient and custom registries
new DisplayItemClassificationTypeProvider().RegisterAll();
new DisplayItemClassificationTypeProvider(consoleWindowRegistry).RegisterAll();
The comment talks about the ambient registry, but I don't see any reference to it in the method, other than it being added to the combo box.
It isn't clear to me if I should use AmbientHighlightingStyleRegistry.Instance.Register() or "new CmdVarClassificationTypeProvider().RegisterAll()". Based on your suggestion, I changed to this, which seems to be working fine:
static readonly CmdVarClassificationTypeProvider classificationTypeProvider = new CmdVarClassificationTypeProvider();
static readonly List<IClassificationType> ClassificationTypes = new List<IClassificationType>
{
classificationTypeProvider.Default,
classificationTypeProvider.Concept,
classificationTypeProvider.Criteria,
classificationTypeProvider.All,
classificationTypeProvider.Optional,
classificationTypeProvider.Required,
classificationTypeProvider.Pipe
};
//...
public void SetClassificationForegroundColor(string key, SolidColorBrush brush)
{
var classificationType = ClassificationTypes.FirstOrDefault(t => t.Key == key);
if (classificationType != null)
{
var registry = AmbientHighlightingStyleRegistry.Instance;
registry.Register(classificationType, new HighlightingStyle(brush), true);
}
}