TextPane2 接口
表示文本编辑器窗口内的窗格。
命名空间: EnvDTE80
程序集: EnvDTE80(在 EnvDTE80.dll 中)
语法
声明
<GuidAttribute("ACE19C7B-A0AC-4089-94FD-749CF4380E1F")> _
Public Interface TextPane2 _
Inherits TextPane
[GuidAttribute("ACE19C7B-A0AC-4089-94FD-749CF4380E1F")]
public interface TextPane2 : TextPane
[GuidAttribute(L"ACE19C7B-A0AC-4089-94FD-749CF4380E1F")]
public interface class TextPane2 : TextPane
[<GuidAttribute("ACE19C7B-A0AC-4089-94FD-749CF4380E1F")>]
type TextPane2 =
interface
interface TextPane
end
public interface TextPane2 extends TextPane
TextPane2 类型公开以下成员。
属性
名称 | 说明 | |
---|---|---|
Collection | (继承自 TextPane。) | |
Collection | 获取包含支持此属性的 TextPane 对象的集合。 | |
DTE | (继承自 TextPane。) | |
DTE | 获取顶级扩展性对象。 | |
Height | (继承自 TextPane。) | |
Height | 获取文本窗格的高度(以字符为单位)。 | |
IncrementalSearch | 提供对文本编辑器的渐进式搜索 (ISearch) 功能的访问。 | |
Selection | (继承自 TextPane。) | |
Selection | 获取表示 TextPane 对象上当前选定内容的对象。 | |
StartPoint | (继承自 TextPane。) | |
StartPoint | 获取表示窗格显示的第一个字符的 TextPoint 对象。 | |
Width | (继承自 TextPane。) | |
Width | 获取窗格的宽度(以字符为单位)。 | |
Window | (继承自 TextPane。) | |
Window | 获取包含窗格的 Window 对象。 |
页首
方法
名称 | 说明 | |
---|---|---|
Activate() | (继承自 TextPane。) | |
Activate() | 将焦点移至当前项。 | |
IsVisible(TextPoint, Object) | (继承自 TextPane。) | |
IsVisible(TextPoint, Object) | 返回一个指示该字符或指定字符在文本窗格中是否可见的值。 | |
TryToShow(TextPoint, vsPaneShowHow, Object) | (继承自 TextPane。) | |
TryToShow(TextPoint, vsPaneShowHow, Object) | 如果可能,调整视图在文本缓冲区中的位置,以便在文本窗格中显示指示的文本范围。您可以控制文本在窗格中的显示位置。 |
页首
备注
可以将文本编辑器窗口拆分成两个窗格。 TextPane 对象使您可以访问每个窗格中的选定文本以及窗格的属性(如高度、宽度等)。
示例
此示例打开一个文本文档并在消息框中显示某些文本窗格属性。 有关如何作为外接程序运行此示例的更多信息,请参见 如何:编译和运行自动化对象模型代码示例。
Imports EnvDTE
Imports EnvDTE80
Public Sub OnConnection(ByVal application As Object, _
ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
ByRef custom As Array) Implements IDTExtensibility2.OnConnection
_applicationObject = CType(application, DTE2)
_addInInstance = CType(addInInst, AddIn)
TextPane2Example(_applicationObject)
End Sub
Sub TextPane2Example(ByVal dte As DTE2)
Dim objTW As TextWindow
Dim objPane As TextPane2
Dim objStart As TextPoint
Dim objTextDoc As TextDocument
Dim objTextPt As TextPoint
Dim objEP As EditPoint
' Create a new text document.
_applicationObject.ItemOperations.NewFile("General\Text File")
' Get a handle to the new document and create EditPoint,
' TextPoint, and TextPane2 objects.
objTextDoc = CType(_applicationObject.ActiveDocument.Object _
("TextDocument"), TextDocument)
objEP = objTextDoc.StartPoint.CreateEditPoint
objTextPt = objTextDoc.StartPoint
' Plug in some text.
objEP.Insert("A test sentence.")
objTW = CType(dte.ActiveWindow.Object, TextWindow)
objPane = CType(objTW.ActivePane, TextPane2)
MsgBox("The active pane is " & Str(objPane.Height) _
& " lines high and " & Str(objPane.Width) & " columns wide.")
objStart = objPane.StartPoint
MsgBox("It begins at line " & Str(objStart.Line) & ", column " & _
Str(objStart.LineCharOffset) & ".")
End Sub
using EnvDTE;
using EnvDTE80;
using System.Windows.Forms;
public void OnConnection(object application,
ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
TextPane2Example(_applicationObject);
}
public void TextPane2Example(DTE2 dte)
{
TextWindow objTW;
TextPane2 objPane;
TextPoint objStart;
TextDocument objTextDoc;
TextPoint objTextPt;
EditPoint2 objEP;
// Create a new text document.
_applicationObject.ItemOperations.NewFile(@"General\Text File",
"test.txt", Constants.vsViewKindTextView);
// Get a handle to the text document and create EditPoint2,
// TextPoint, and TextPane2 objects.
objTextDoc =(TextDocument)_applicationObject.ActiveDocument.Object
("TextDocument");
objEP = (EditPoint2)objTextDoc.StartPoint.CreateEditPoint();
objTextPt = objTextDoc.StartPoint;
// Plug in some text.
objEP.Insert("A test sentence.");
objTW = (TextWindow)_applicationObject.ActiveWindow.Object;
objPane = (TextPane2)objTW.ActivePane;
MessageBox.Show("The active pane is " + objPane.Height + "
lines high and " + objPane.Width + " columns wide.");
objStart = objPane.StartPoint;
MessageBox.Show("It begins at line " + objStart.Line
+ ", column " + objStart.LineCharOffset + ".");
}