Share via


TextPointer.GetNextInsertionPosition(LogicalDirection) Método

Definição

Retorna um TextPointer para a próxima posição de inserção na direção lógica especificada.

public:
 System::Windows::Documents::TextPointer ^ GetNextInsertionPosition(System::Windows::Documents::LogicalDirection direction);
public System.Windows.Documents.TextPointer GetNextInsertionPosition (System.Windows.Documents.LogicalDirection direction);
member this.GetNextInsertionPosition : System.Windows.Documents.LogicalDirection -> System.Windows.Documents.TextPointer
Public Function GetNextInsertionPosition (direction As LogicalDirection) As TextPointer

Parâmetros

direction
LogicalDirection

Um dos valores LogicalDirection que especifica a direção lógica na qual pesquisar a próxima posição de inserção.

Retornos

TextPointer

Um TextPointer que identifica a próxima posição de inserção na direção solicitada ou null se a próxima posição de inserção não puder ser encontrada.

Exemplos

O exemplo a seguir demonstra um uso para este método. O exemplo usa o GetNextInsertionPosition método para percorrer limites de elemento de conteúdo para contar o número de Paragraph elementos presentes entre duas instâncias especificadas TextPointer .

// This method returns the number of pagragraphs between two
// specified TextPointers.
int GetParagraphCount(TextPointer start, TextPointer end)
{
    int paragraphCount = 0;
 
    while (start != null && start.CompareTo(end) < 0)
    {
        Paragraph paragraph = start.Paragraph;
 
        if (paragraph != null)
        {
            paragraphCount++;
 
            // Advance start to the end of the current paragraph.
            start = paragraph.ContentEnd;
         }
 
         // Use the GetNextInsertionPosition method to skip over any interceding
         // content element tags.
         start = start.GetNextInsertionPosition(LogicalDirection.Forward);
     } // End while.
 
         return paragraphCount;
}  // End GetParagraphCount.
' This method returns the number of pagragraphs between two
' specified TextPointers.
Private Function GetParagraphCount(ByVal start As TextPointer, ByVal [end] As TextPointer) As Integer
    Dim paragraphCount As Integer = 0

    Do While start IsNot Nothing AndAlso start.CompareTo([end]) < 0
        Dim paragraph As Paragraph = start.Paragraph

        If paragraph IsNot Nothing Then
            paragraphCount += 1

            ' Advance start to the end of the current paragraph.
            start = paragraph.ContentEnd
        End If

        ' Use the GetNextInsertionPosition method to skip over any interceding
        ' content element tags.
        start = start.GetNextInsertionPosition(LogicalDirection.Forward)

    Loop ' End while.

    Return paragraphCount

End Function ' End GetParagraphCount.

Comentários

Uma posição de inserção é uma posição em que o novo conteúdo pode ser adicionado sem violar nenhuma regra semântica para o conteúdo associado. Na prática, uma posição de inserção está em qualquer lugar no conteúdo em que um caret pode ser posicionado. Um exemplo de uma posição válida TextPointer que não é uma posição de inserção é a posição entre duas marcas adjacentes Paragraph (ou seja, entre a marca de fechamento do parágrafo anterior e a marca de abertura do parágrafo seguinte).

Aplica-se a

Confira também