【发布时间】:2016-08-20 11:38:12
【问题描述】:
我正在 Visual Studio 中为 Properties language 构建语法突出显示扩展,并且已经构建了分类器/标记器。 然而,我一直在为不同的标签(即键、值、cmets)设置/选择正确的颜色。
我想让颜色遵循 Visual Studio 的当前主题。现在它们是硬编码的(请参阅ForegroundColor = ...): p>
[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = "PropertiesKeyTypeDefinition")]
[Name("PropertiesKeyFormat")]
[Order(Before = Priority.Default)]
internal sealed class PropertiesKey : ClassificationFormatDefinition {
public PropertiesKey() {
DisplayName = "Properties Key";
ForegroundColor = Color.FromRgb(86, 156, 214);
}
}
到目前为止我发现了什么:
- This question 假设我的问题已经得到解答。
- This answer 显示了可以在注册表中存储颜色的位置,但这不是一个可靠的解决方案。
- This question 解决 WPF 的颜色问题(不是我的情况)
- 有 Extensibility Tools 扩展名和 Theme Swatches 显示来自 EnvironmentColors 的颜色,但是我不知道如何使用它提供的 C# 代码
如果可能的话,我想使用用于 'Keyword'、'String' 和 'Comment' 的颜色,这些颜色可以在 VS 中的Tools -> Options -> Environment -> Fonts and Colors 中找到,同样,按照当前主题。
【问题讨论】:
标签: c# visual-studio plugins syntax-highlighting vsix