Export (0) Print
Expand All

EditPoint.EqualTo Method

Returns a value indicating whether the value of the given point object's AbsoluteCharOffset is equal to that of the calling EditPoint object.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

bool EqualTo(
	TextPoint Point
)

Parameters

Point
Type: EnvDTE.TextPoint

Required. A TextPoint object to compare to the calling EditPoint point object.

Return Value

Type: System.Boolean
true if Point has the same AbsoluteCharOffset property value as the calling EditPoint point object; otherwise, false.

EqualTo throws a ArgumentException exception if Point is not in the same document as the calling point object. With the VirtualPoint, EqualTo compares the virtual positions if the argument is a VirtualPoint. Otherwise, it compares the "physical" positions.

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.");
}

Show:
© 2014 Microsoft