TextPatternRange.CompareEndpoints Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Devuelve un valor Int32 que indica si dos intervalos de texto tienen puntos de conexión 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
Intervalo de destino para la comparación.
- targetEndpoint
- TextPatternRangeEndpoint
Devoluciones
Devuelve un valor negativo si el punto de conexión del autor de la llamada se produce anteriormente en el texto que el punto de conexión de destino.
Devuelve cero si el punto de conexión del autor de la llamada está en la misma ubicación que el punto de conexión de destino.
Devuelve un valor positivo si el punto de conexión del autor de la llamada se produce más adelante en el texto que el punto de conexión de destino.
Excepciones
Si range es una referencia nula (Nothing en Visual Basic).
Si el intervalo es de otro contenedor.
Ejemplos
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
Comentarios
Al comparar los puntos de conexión inicial y final del mismo intervalo de texto, puede identificar si se degenera un intervalo de texto o si los puntos de conexión están en el orden del flujo de texto lógico.