다음을 통해 공유


TextPatternRange.CompareEndpoints 메서드

정의

두 텍스트 범위의 엔드포인트가 동일한지 여부를 나타내는 Int32를 반환합니다.

public:
 int CompareEndpoints(System::Windows::Automation::Text::TextPatternRangeEndpoint endpoint, System::Windows::Automation::Text::TextPatternRange ^ targetRange, System::Windows::Automation::Text::TextPatternRangeEndpoint targetEndpoint);
public int CompareEndpoints (System.Windows.Automation.Text.TextPatternRangeEndpoint endpoint, System.Windows.Automation.Text.TextPatternRange targetRange, System.Windows.Automation.Text.TextPatternRangeEndpoint targetEndpoint);
member this.CompareEndpoints : System.Windows.Automation.Text.TextPatternRangeEndpoint * System.Windows.Automation.Text.TextPatternRange * System.Windows.Automation.Text.TextPatternRangeEndpoint -> int
Public Function CompareEndpoints (endpoint As TextPatternRangeEndpoint, targetRange As TextPatternRange, targetEndpoint As TextPatternRangeEndpoint) As Integer

매개 변수

endpoint
TextPatternRangeEndpoint

호출자의 Start 또는 End 엔드포인트입니다.

targetRange
TextPatternRange

비교할 대상 범위입니다.

targetEndpoint
TextPatternRangeEndpoint

대상의 Start 또는 End 엔드포인트입니다.

반환

Int32

텍스트에서 호출자의 엔드포인트이 대상 엔드포인트보다 먼저 나타나면 음수 값을 반환합니다.

호출자의 엔드포인트이 대상 엔드포인트과 같은 위치에 있으면 0을 반환합니다.

텍스트에서 호출자의 엔드포인트이 대상 엔드포인트보다 나중에 나타나면 양수 값을 반환합니다.

예외

범위가 null 참조(Visual Basic에서는 Nothing)인 경우

범위를 다른 컨테이너에서 가져온 경우

예제

private Int32 CompareRangeEndpoints(AutomationElement target)
{
    // Specify the control type we're looking for, in this case 'Document'
    PropertyCondition cond = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document);

    // target --> The root AutomationElement.
    AutomationElement textProvider = target.FindFirst(TreeScope.Descendants, cond);

    TextPattern textpatternPattern = textProvider.GetCurrentPattern(TextPattern.Pattern) as TextPattern;

    if (textpatternPattern == null)
    {
        Console.WriteLine("Root element does not contain a descendant that supports TextPattern.");
        return 0;
    }
    TextPatternRange[] currentSelections = textpatternPattern.GetSelection();
    TextPatternRange[] currentVisibleRanges = textpatternPattern.GetVisibleRanges();
    return currentSelections[0].CompareEndpoints(
        TextPatternRangeEndpoint.Start, 
        currentVisibleRanges[0], 
        TextPatternRangeEndpoint.Start);
}
Private Function CompareRangeEndpoints(ByVal target As AutomationElement) As Integer
    ' Specify the control type we're looking for, in this case 'Document'
    Dim cond As PropertyCondition = New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document)

    ' target --> The root AutomationElement.
    Dim textProvider As AutomationElement = target.FindFirst(TreeScope.Descendants, cond)

    Dim textpatternPattern As TextPattern = CType(textProvider.GetCurrentPattern(TextPattern.Pattern), TextPattern)

    If (textpatternPattern Is Nothing) Then
        Console.WriteLine("Root element does not contain a descendant that supports TextPattern.")
        Return Nothing
    End If
    Dim currentSelection As TextPatternRange() = textpatternPattern.GetSelection()
    Dim currentVisibleRanges As TextPatternRange() = textpatternPattern.GetVisibleRanges()
    Return currentSelection(0).CompareEndpoints(TextPatternRangeEndpoint.Start, _
                                         currentVisibleRanges(0), _
                                         TextPatternRangeEndpoint.Start)
End Function

설명

동일한 텍스트 범위의 시작 및 끝 엔드포인트을 비교 하 여 텍스트 범위를 중복 제거 되었는지 또는 논리적 텍스트 흐름 순서는 엔드포인트을 식별할 수 있습니다.

적용 대상

추가 정보