如何在VS2010文本装饰扩展中更改文本的颜色和粗细?
在我的 TextAdornment1 类中,我定义了以下内容:
' <summary>'
' On layout change add the adornment to any reformatted lines'
' </summary>'
Private Sub OnLayoutChanged(ByVal sender As Object, ByVal e As TextViewLayoutChangedEventArgs) Handles _view.LayoutChanged
For Each line In e.NewOrReformattedLines
Me.CreateVisuals(line)
Next line
End Sub
ITextViewLine
的实例被传递到我的 CreateVisuals
方法。如何更改该特定行上文本的颜色,以及如何将其设置为粗体?我看到很多绘制图像来突出显示文本的示例,但到目前为止还没有任何改变实际文本的格式的例子。我该怎么做?
In my TextAdornment1 class, I have the following defined:
' <summary>'
' On layout change add the adornment to any reformatted lines'
' </summary>'
Private Sub OnLayoutChanged(ByVal sender As Object, ByVal e As TextViewLayoutChangedEventArgs) Handles _view.LayoutChanged
For Each line In e.NewOrReformattedLines
Me.CreateVisuals(line)
Next line
End Sub
An instance of ITextViewLine
gets passed to my CreateVisuals
method. How do I change the color of the text on that particular line, and how do I make it bold? I see plenty of examples of drawing images to highlight text, but nothing so far that changes the formatting of the actual text. How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为这可以通过装饰来完成(据我所知,它们只向窗口添加元素,而不改变现有元素)。
我建议您查看“编辑器分类器”,它允许您更改文本的格式(VS SDK 包含一个很好的分类器项目模板)。
I don't think this can be done via the adornments (AFAIK, they only add elements to the window, not alter existing ones).
I recommend you look into the "Editor Classifiers" which will allow you to alter the formatting of text (the VS SDK includes a good project template for classifiers).