TextPatternRange.ExpandToEnclosingUnit(TextUnit) Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Développe la plage de texte à l’objet spécifié TextUnit.
public:
void ExpandToEnclosingUnit(System::Windows::Automation::Text::TextUnit unit);
public void ExpandToEnclosingUnit(System.Windows.Automation.Text.TextUnit unit);
member this.ExpandToEnclosingUnit : System.Windows.Automation.Text.TextUnit -> unit
Public Sub ExpandToEnclosingUnit (unit As TextUnit)
Paramètres
- unit
- TextUnit
Unité textuelle.
Exemples
private void ExpandSelection(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;
}
TextPatternRange[] currentSelection = textpatternPattern.GetSelection();
// Expand selection to include entire document
currentSelection[0].ExpandToEnclosingUnit(TextUnit.Document);
}
Private Sub ExpandSelection(ByVal target As AutomationElement)
' 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
End If
Dim currentSelection As TextPatternRange() = textpatternPattern.GetSelection()
currentSelection(0).ExpandToEnclosingUnit(TextUnit.Document)
End Sub
Remarques
Si la plage est déjà une quantité exacte des unités spécifiées, elle reste inchangée.
Pour que la ExpandToEnclosingUnit méthode s’exécute correctement, une séquence d’actions est effectuée en arrière-plan.
La plage de texte est normalisée ; autrement dit, la plage de texte est réduite à une plage dégénérée au niveau du Start point de terminaison, ce qui rend le End point de terminaison superflu. Cette étape est nécessaire pour supprimer l’ambiguïté dans les situations où une plage de texte s’étend sur des
unitlimites ; par exemple, « {La liste de révocation de certificats U} https://www.microsoft.com/ est incorporée dans le texte » où « { » et « } » sont les points de terminaison de plage de texte.La plage résultante est déplacée vers l’arrière dans le DocumentRange jusqu’au début de la limite demandée
unit.La plage est avancée ou reculée dans DocumentRange du nombre demandé de limites
unit.La plage est ensuite étendue à partir d'un état de plage dégénérée en déplaçant le point de terminaison End d'une limite
unitdemandée.
Exemples de l’ajustement d’une plage de texte pour Move() et ExpandToEnclosingUnit()
Note
Ces étapes sont nécessaires, car il est courant pour un lecteur d’écran de lire un mot, une phrase ou un paragraphe entier au point d’insertion ou à toute position de curseur virtuel.
ExpandToEnclosingUnit respecte le texte masqué et visible. Le client UI Automation peut vérifier la visibilité du texte IsHiddenAttribute.
ExpandToEnclosingUnit reporte la plus grande TextUnit prise en charge suivante si l’élément donné TextUnit n’est pas pris en charge par le contrôle.
L’ordre, de la plus petite unité au plus grand, est répertorié ci-dessous.