Cet article a fait l'objet d'une traduction automatique. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. Informations supplémentaires.
Traduction
Source
Ce sujet n'a pas encore été évalué - Évaluez ce sujet

TextPattern.IsSubscriptAttribute, champ

Identifie l'attribut IsSubscript (FontVariants) d'une plage de texte.

Espace de noms :  System.Windows.Automation
Assembly :  UIAutomationClient (dans UIAutomationClient.dll)
public static readonly AutomationTextAttribute IsSubscriptAttribute

Cet identificateur est utilisé par les applications du client UI Automation. Les fournisseurs UI Automation doivent utiliser le champ équivalent dans TextPatternIdentifiers.

Les clients UI Automation obtiennent la valeur de l'attribut en appelant GetAttributeValue.

Les valeurs de cet attribut sont de type Boolean. La valeur par défaut est false.

L'exemple suivant montre comment obtenir une valeur d'attribut d'une plage de texte dans le Bloc-notes Microsoft.

RemarqueRemarque

Bloc-notes Microsoft est utilisé comme fournisseur de texte à titre d'exemple uniquement. Il n'est pas garanti que Bloc-notes Microsoft prenne en charge la valeur d'attribut demandée.


private void GetIsSubscriptAttribute()
{
    // Start application.
    Process p = Process.Start("Notepad.exe", "text.txt");

    // target --> The root AutomationElement.
    AutomationElement target = AutomationElement.FromHandle(p.MainWindowHandle);

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

    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;
    }

    Object oAttribute = textpatternPattern.DocumentRange.GetAttributeValue(TextPattern.IsSubscriptAttribute);
    if (oAttribute == TextPattern.MixedAttributeValue)
    {
        Console.WriteLine("Mixture of subscript and non-subscript.");
    }
    else
    {
        Console.WriteLine(oAttribute.ToString());
    }
}



Private Sub GetIsSubscriptAttribute()
    ' Start application.
    Dim p As Process = Process.Start("Notepad.exe", "text.txt")

    ' target --> The root AutomationElement.
    Dim target As AutomationElement = AutomationElement.FromHandle(p.MainWindowHandle)

    ' Specify the control type we're looking for, in this case 'Document'
    Dim cond As PropertyCondition = New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document)

    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
    End If

    Dim oAttribute As Object = textpatternPattern.DocumentRange.GetAttributeValue(TextPattern.IsSubscriptAttribute)
    If (oAttribute = TextPattern.MixedAttributeValue) Then
        Console.WriteLine("Mixture of subscript and non-subscript.")
    Else
        Console.WriteLine(oAttribute.ToString())
    End If
End Sub


.NET Framework

Pris en charge dans : 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Pris en charge dans : 4, 3.5 SP1

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (rôle principal du serveur non pris en charge), Windows Server 2008 R2 (rôle principal du serveur pris en charge avec SP1 ou version ultérieure ; Itanium non pris en charge)

Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.
Cela vous a-t-il été utile ?
(1500 caractères restants)

Ajouts de la communauté

AJOUTER
© 2013 Microsoft. Tous droits réservés.