TextPattern.GetVisibleRanges 메서드

정의

각 텍스트 범위가 부분적으로 표시되는 첫 번째 줄부터 마지막으로 부분적으로 표시되는 줄의 끝까지 시작되는 텍스트 컨테이너에서 연결이 끊긴 텍스트 범위의 배열을 검색합니다.

public:
 cli::array <System::Windows::Automation::Text::TextPatternRange ^> ^ GetVisibleRanges();
public System.Windows.Automation.Text.TextPatternRange[] GetVisibleRanges();
member this.GetVisibleRanges : unit -> System.Windows.Automation.Text.TextPatternRange[]
Public Function GetVisibleRanges () As TextPatternRange()

반품

컨테이너 또는 빈 배열 내에서 표시되는 텍스트 범위의 컬렉션입니다. Null 가 반환되지 않습니다.

예제

private TextPatternRange[] CurrentVisibleRanges(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 null;
    }
    return textpatternPattern.GetVisibleRanges();
}
Private Function CurrentVisibleRanges(ByVal target As AutomationElement) As TextPatternRange()
    ' 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

    Return textpatternPattern.GetVisibleRanges()
End Function

설명

연결되지 않은 텍스트 범위는 텍스트 컨테이너의 내용이 겹치는 창이나 다른 개체에 의해 가려지거나 다중 열 레이아웃이 있는 텍스트 컨테이너에 하나 이상의 열이 부분적으로 스크롤되어 보이지 않는 경우에 발생할 수 있습니다.

텍스트가 표시되지 않으면 퇴행(빈) 텍스트 범위가 반환됩니다. 텍스트 컨테이너가 비어 있거나 모든 텍스트가 보기 밖으로 스크롤되는 경우 이 빈 범위를 반환할 수 있습니다.

적용 대상

추가 정보