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 엔드포인트입니다.

반품

호출자의 엔드포인트가 대상 엔드포인트보다 이전 텍스트에서 발생하는 경우 음수 값을 반환합니다.

호출자의 엔드포인트가 대상 엔드포인트와 동일한 위치에 있으면 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

설명

동일한 텍스트 범위의 시작 엔드포인트와 끝 엔드포인트를 비교하여 텍스트 범위가 퇴화되는지 또는 엔드포인트가 논리 텍스트 흐름 순서에 있는지 여부를 식별할 수 있습니다.

적용 대상

추가 정보