TextPointer.GetNextInsertionPosition(LogicalDirection) 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.
Retorna a 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 para procurar a próxima posição de inserção.
Devoluções
A que identifica a próxima posição de inserção na direção solicitada, ou null se não for possível encontrar a TextPointer próxima posição de inserção.
Exemplos
O exemplo seguinte demonstra a utilização deste método. O exemplo utiliza o GetNextInsertionPosition método para atravessar os limites dos elementos 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.
Observações
Uma posição de inserção é uma posição onde pode ser adicionado novo conteúdo sem violar quaisquer regras semânticas para o conteúdo associado. Na prática, uma posição de inserção é em qualquer ponto do conteúdo onde um caret possa ser posicionado. Um exemplo de posição válida TextPointer que não é uma posição de inserção é a posição entre duas etiquetas adjacentes Paragraph (isto é, entre a etiqueta de encerramento do parágrafo anterior e a etiqueta de abertura do parágrafo seguinte).