TextPatternRange.CompareEndpoints Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Devolve um Int32 indicando se dois intervalos de texto têm terminais idênticos.
public:
int CompareEndpoints(System::Windows::Automation::Text::TextPatternRangeEndpoint endpoint, System::Windows::Automation::Text::TextPatternRange ^ targetRange, System::Windows::Automation::Text::TextPatternRangeEndpoint targetEndpoint);
public int CompareEndpoints(System.Windows.Automation.Text.TextPatternRangeEndpoint endpoint, System.Windows.Automation.Text.TextPatternRange targetRange, System.Windows.Automation.Text.TextPatternRangeEndpoint targetEndpoint);
member this.CompareEndpoints : System.Windows.Automation.Text.TextPatternRangeEndpoint * System.Windows.Automation.Text.TextPatternRange * System.Windows.Automation.Text.TextPatternRangeEndpoint -> int
Public Function CompareEndpoints (endpoint As TextPatternRangeEndpoint, targetRange As TextPatternRange, targetEndpoint As TextPatternRangeEndpoint) As Integer
Parâmetros
- endpoint
- TextPatternRangeEndpoint
- targetRange
- TextPatternRange
A distância do alvo para comparação.
- targetEndpoint
- TextPatternRangeEndpoint
Devoluções
Devolve um valor negativo se o ponto final do chamador ocorrer mais cedo no texto do que o endpoint de destino.
Retorna zero se o endpoint do chamador estiver na mesma localização que o endpoint alvo.
Devolve um valor positivo se o endpoint do chamador ocorrer mais tarde no texto do que o endpoint de destino.
Exceções
Se o alcance for uma referência nula (Nothing em Visual Basic).
Se o alcance for de outro recipiente.
Exemplos
private Int32 CompareRangeEndpoints(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 0;
}
TextPatternRange[] currentSelections = textpatternPattern.GetSelection();
TextPatternRange[] currentVisibleRanges = textpatternPattern.GetVisibleRanges();
return currentSelections[0].CompareEndpoints(
TextPatternRangeEndpoint.Start,
currentVisibleRanges[0],
TextPatternRangeEndpoint.Start);
}
Private Function CompareRangeEndpoints(ByVal target As AutomationElement) As Integer
' 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 currentVisibleRanges As TextPatternRange() = textpatternPattern.GetVisibleRanges()
Return currentSelection(0).CompareEndpoints(TextPatternRangeEndpoint.Start, _
currentVisibleRanges(0), _
TextPatternRangeEndpoint.Start)
End Function
Observações
Ao comparar os pontos finais iniciais e finais do mesmo intervalo de texto, pode identificar se um intervalo de texto é degenerado ou se os pontos finais estão na ordem do fluxo lógico do texto.