![](/img/trans.png)
[英]How to show the window “Add connection” from the extension for Visual Studio?
[英]Add Custom Color Definitions to Output Window in Visual Studio Extension
使用扩展名将自定义颜色定义添加到“字体和颜色”对话框的“文本编辑器”类别中相当容易。 通常只定义并导出新的分类类型和编辑器定义,并使用UserVisible(true)属性对其进行装饰。 这是一个例子。
public static class OutputClassificationDefinitions
{
[Export]
[Name("SomeName")]
public static readonly ClassificationTypeDefinition BuildHeaderDefinition;
[Name("SomeName")]
[UserVisible(true)]
[Export(typeof(EditorFormatDefinition))]
[ClassificationType(ClassificationTypeNames = "SomeName")]
public sealed class BuildHeaderFormat : ClassificationFormatDefinition
{
public BuildHeaderFormat()
{
ForegroundColor = Properties.Settings.Default.BuildHeaderForerground;
BackgroundColor = Properties.Settings.Default.BuildHeaderBackground;
}
}
“SomeName”显示在“文本编辑器”类别下的F&C对话框中。 如果用户更改“SomeName”的颜色,则会记住它,并更新编辑器的格式映射以使用新颜色。
我想为输出窗口做类似的事情。 您可以为输出窗口编写分类器,它可以正常工作。 我在StackOverflow上得到了另一个帖子的想法,它的工作非常出色。
但是,新的颜色定义显示在“文本编辑器”类别中,而不是输出窗口类别,这是首选。 更令人讨厌的是,用户颜色更改不会更新输出窗口的formatMap,这意味着新颜色不会生效。
我已经尝试过更新formatMap,如下所示:
[Import]
internal IClassificationFormatMapService ClassificationFormatMapService;
var formatMap = ClassificationFormatMapService.GetClassificationFormatMap(FontsAndColorsCategory.Outputwindow);
var type = ClassificationRegistry.GetClassificationType("SomeName");
formatMap.AddExplicitTextProperties(type, formatMap.GetExplicitTextProperties(type));
这不起作用。 没有引发异常或错误,只是没有做任何事情。
有没有将我的自定义定义添加到F&C对话框的“输出窗口”类别,更重要的是,更改是否更新了输出窗口?
好吧,答案似乎是根据微软你不能做我想做的事情。 我并不完全相信,但这里提出的论点是令人信服的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.