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 LogicalDirection valores que especifica a direção lógica na qual pesquisar a próxima posição de inserção.

Retornos

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

Exemplos

O exemplo a seguir demonstra um uso para esse método. O exemplo usa o GetNextInsertionPosition método para percorrer os limites do 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 regras semânticas para o conteúdo associado. Na prática, uma posição de inserção está em qualquer lugar no conteúdo em que um cursor pode ser posicionado. Um exemplo de uma posição de TextPointer válida que não é uma posição de inserção é a posição entre duas marcas de Paragraph adjacentes (ou seja, entre a marca de fechamento do parágrafo anterior e a marca de abertura do próximo parágrafo).

Aplica-se a

Confira também