TextPatternRange.Compare(TextPatternRange) 메서드

정의

Boolean 텍스트 범위의 범위(Start엔드포인트에서 엔드포인트까지End)가 다른 텍스트 범위와 같은지 여부를 나타내는 값을 반환합니다.

public:
 bool Compare(System::Windows::Automation::Text::TextPatternRange ^ range);
public bool Compare(System.Windows.Automation.Text.TextPatternRange range);
member this.Compare : System.Windows.Automation.Text.TextPatternRange -> bool
Public Function Compare (range As TextPatternRange) As Boolean

매개 변수

range
TextPatternRange

비교할 텍스트 범위입니다.

반품

true 두 텍스트 범위의 범위가 같으면 이고, 그렇지 않으면 false.

예외

비교되는 범위가 동일한 텍스트 공급자에서 제공되지 않는 경우

예제

private Boolean CompareRanges(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 false;
    }
    TextPatternRange[] currentSelection = textpatternPattern.GetSelection();
    TextPatternRange[] currentVisibleRanges = textpatternPattern.GetVisibleRanges();
    return currentSelection[0].Compare(currentVisibleRanges[0]);
}
Private Function CompareRanges(ByVal target As AutomationElement) As Boolean
    ' 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 currentVisibleRange As TextPatternRange() = textpatternPattern.GetVisibleRanges()
    Return currentSelection(0).Compare(currentVisibleRange(0))
End Function

적용 대상

추가 정보