TextPattern.FontNameAttribute 필드

정의

텍스트 범위의 FontName 특성을 식별합니다.

public: static initonly System::Windows::Automation::AutomationTextAttribute ^ FontNameAttribute;
public static readonly System.Windows.Automation.AutomationTextAttribute FontNameAttribute;
 staticval mutable FontNameAttribute : System.Windows.Automation.AutomationTextAttribute
Public Shared ReadOnly FontNameAttribute As AutomationTextAttribute 

필드 값

AutomationTextAttribute

예제

다음 예제에서는 Microsoft 메모장의 텍스트 범위에 대 한 특성 값을 가져오는 방법을 보여 줍니다.

참고

Microsoft 메모장 텍스트 공급자 예를 들어 목적 으로만 사용 됩니다. 요청 된 특성 값을 지원 하도록 Microsoft 메모장 보장 되지 않습니다.

/// -------------------------------------------------------------------
/// <summary>
/// Outputs the FontNameAttribute value for a range of text.
/// </summary>
/// <param name="targetTextElement">
/// The AutomationElment that represents a text control.
/// </param>
/// -------------------------------------------------------------------
private void GetFontNameAttribute(AutomationElement targetTextElement)
{
    TextPattern textPattern = 
        targetTextElement.GetCurrentPattern(TextPattern.Pattern) as TextPattern;

    if (textPattern == null)
    {
        // Target control doesn't support TextPattern.
        return;
    }

    // If the target control doesn't support selection then return.
    // Otherwise, get the text attribute for the selected text.
    // If there are currently no selections then the text attribute 
    // will be obtained from the insertion point.
    TextPatternRange[] textRanges;
    if (textPattern.SupportedTextSelection == SupportedTextSelection.None)
    {
        return;
    }
    else
    {
        textRanges = textPattern.GetSelection();
    }

    foreach (TextPatternRange textRange in textRanges)
    {
        Object textAttribute =
            textRange.GetAttributeValue(
            TextPattern.FontNameAttribute);

        if (textAttribute == TextPattern.MixedAttributeValue)
        {
            // Returns MixedAttributeValue if the value of the 
            // specified attribute varies over the text range. 
            Console.WriteLine("Mixed fonts.");
        }
        else if (textAttribute == AutomationElement.NotSupported)
        {
            // Returns NotSupported if the specified attribute is 
            // not supported by the provider or the control. 
            Console.WriteLine(
                "FontNameAttribute not supported by provider.");
        }
        else
        {
            Console.WriteLine(textAttribute.ToString());
        }
    }
}
''' -------------------------------------------------------------------
''' <summary>
''' Outputs the FontNameAttribute value for a range of text.
''' </summary>
''' <param name="targetTextElement">
''' The AutomationElement. that represents the text provider.
''' </param>
''' -------------------------------------------------------------------
Private Sub GetFontNameAttribute( _
ByVal targetTextElement As AutomationElement)
    Dim targetTextPattern As TextPattern = _
        DirectCast(targetTextElement.GetCurrentPattern( _
        TextPattern.Pattern), TextPattern)

    If (targetTextPattern Is Nothing) Then
        ' Target control doesn't support TextPattern.
        Return
    End If

    ' If the target control doesn't support selection then return.
    ' Otherwise, get the text attribute for the selected text.
    ' If there are currently no selections then the text attribute 
    ' will be obtained from the insertion point.
    Dim textRanges() As TextPatternRange
    If (targetTextPattern.SupportedTextSelection = SupportedTextSelection.None) Then
        Return
    Else
        textRanges = targetTextPattern.GetSelection()
    End If

    Dim textRange As TextPatternRange
    For Each textRange In textRanges
        Dim textAttribute As Object = _
            textRange.GetAttributeValue( _
            TextPattern.FontNameAttribute)

        If (textAttribute = TextPattern.MixedAttributeValue) Then
            ' Returns MixedAttributeValue if the value of the 
            ' specified attribute varies over the text range. 
            Console.WriteLine("Mixed fonts.")
        ElseIf (textAttribute = AutomationElement.NotSupported) Then
            ' Returns NotSupported if the specified attribute is 
            ' not supported by the provider or the control. 
            Console.WriteLine( _
            "FontNameAttribute not supported by provider.")
        Else
            Console.WriteLine(textAttribute.ToString())
        End If
    Next
End Sub

설명

이 특성에 대 한 예제 값에는 "Arial Black" 및 "Arial 좁은" 포함 됩니다.

이 특성에 대 한 값은 지역화 되지 않은 합니다.

이 식별자는 UI 자동화 클라이언트 애플리케이션에서 사용 됩니다. UI 자동화 공급자의 해당 필드를 사용 해야 TextPatternIdentifiers합니다.

UI 자동화 클라이언트를 호출 하 여 특성의 값을 가져올 GetAttributeValue합니다.

이 특성의 값은 형식의 String합니다. 기본값은는 empty string합니다.

적용 대상

추가 정보