次の方法で共有


EditPoint.EqualTo メソッド (TextPoint)

指定したポイントのオブジェクトの AbsoluteCharOffset の値が、呼び出し元の EditPoint オブジェクトの値に等しいかどうかを示す値を返します。

名前空間:  EnvDTE
アセンブリ:  EnvDTE (EnvDTE.dll 内)

構文

'宣言
Function EqualTo ( _
    Point As TextPoint _
) As Boolean
bool EqualTo(
    TextPoint Point
)
bool EqualTo(
    [InAttribute] TextPoint^ Point
)
abstract EqualTo : 
        Point:TextPoint -> bool 
function EqualTo(
    Point : TextPoint
) : boolean

パラメーター

戻り値

型: System.Boolean
Point の AbsoluteCharOffset プロパティ値が、呼び出しポイントの EditPoint オブジェクトのプロパティ値と同じである場合は true。それ以外の場合は false。

実装

TextPoint.EqualTo(TextPoint)

解説

Point が呼び出しポイントのオブジェクトと同じドキュメント内にない場合、EqualToArgumentException 例外をスローします。 VirtualPoint では、EqualTo は、引数が VirtualPoint の場合には仮想位置を比較します。 それ以外の場合は、"物理" 位置を比較します。

Sub EqualToExample(ByVal dte As DTE2)

    ' Create a new text file.
    dte.ItemOperations.NewFile()
    Dim txtDoc As TextDocument = _
        CType(dte.ActiveDocument.Object(), TextDocument)

    ' Create an edit point at the empty text document's StartPoint 
    ' and EndPoint; CompareEditPoints displays "point1 and point2
    ' occupy the same location."
    Dim point1 As EditPoint = txtDoc.StartPoint.CreateEditPoint()
    Dim point2 As EditPoint = txtDoc.EndPoint.CreateEditPoint()
    CompareEditPoints(point1, point2)

    ' Insert ten lines of text.
    Dim i As Integer
    For i = 1 To 10
        point1.Insert("Line " & i.ToString() & vbCrLf)
    Next

    ' Create an edit point at the text document's StartPoint and 
    ' EndPoint; CompareEditPoints displays "point1 comes before
    ' point2."
    point1 = txtDoc.StartPoint.CreateEditPoint()
    point2 = txtDoc.EndPoint.CreateEditPoint()
    CompareEditPoints(point1, point2)

End Sub

Sub CompareEditPoints(ByVal point1 As EditPoint, _
    ByVal point2 As EditPoint)

    If point1.LessThan(point2) Then
        MsgBox("point1 comes before point2.")
    ElseIf point1.GreaterThan(point2) Then
        MsgBox("point2 comes before point1.")
    ElseIf (point1.EqualTo(point2)) Then
        MsgBox("point1 and point2 occupy the same location.")
    End If

End Sub
public void EqualToExample(DTE2 dte)
{

    // Create a new text file.
    dte.ItemOperations.NewFile(@"General\Text File", "", 
        Constants.vsViewKindPrimary);
    TextDocument txtDoc = 
        (TextDocument)dte.ActiveDocument.Object("TextDocument");

    // Create an edit point at the empty text document's StartPoint 
    // and EndPoint; CompareEditPoints displays "point1 and point2
    // occupy the same location."
    EditPoint point1 = txtDoc.StartPoint.CreateEditPoint();
    EditPoint point2 = txtDoc.EndPoint.CreateEditPoint();
    CompareEditPoints(point1, point2);

    // Insert ten lines of text.
    for (int i = 1; i <= 10; i++)
        point1.Insert("Line " + i.ToString() + "\r\n");

    // Create an edit point at the text document's StartPoint and 
    // EndPoint; CompareEditPoints displays "point1 comes before 
    // point2."
    point1 = txtDoc.StartPoint.CreateEditPoint();
    point2 = txtDoc.EndPoint.CreateEditPoint();
    CompareEditPoints(point1, point2);
}

public void CompareEditPoints(EditPoint point1, EditPoint point2)
{
    if (point1.LessThan(point2))
        MessageBox.Show("point1 comes before point2.");
    else if (point1.GreaterThan(point2))
        MessageBox.Show("point2 comes before point1.");
    else if (point1.EqualTo(point2))
        MessageBox.Show("point1 and point2 occupy the same location.");
}

.NET Framework セキュリティ

  • 直前の呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されているコードから使用することはできません。 詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

EditPoint インターフェイス

EqualTo オーバーロード

EnvDTE 名前空間

その他の技術情報

方法 : オートメーション オブジェクト モデルのコード例をコンパイルおよび実行する