TextPointer.GetNextInsertionPosition(LogicalDirection) Metoda

Definicja

Zwraca wartość a TextPointer do następnego położenia wstawiania w określonym kierunku logicznym.

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

Parametry

direction
LogicalDirection

LogicalDirection Jedna z wartości określających kierunek logiczny, w którym należy wyszukać kolejną pozycję wstawiania.

Zwraca

TextPointer

Element TextPointer identyfikujący kolejną pozycję wstawiania w żądanym kierunku lub null jeśli nie można odnaleźć następnego położenia wstawiania.

Przykłady

W poniższym przykładzie pokazano użycie tej metody. W przykładzie użyto GetNextInsertionPosition metody przechodzenia przez granice elementów zawartości w celu zliczenia liczby Paragraph elementów znajdujących się między dwoma określonymi TextPointer wystąpieniami.

// 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.

Uwagi

Pozycja wstawiania to pozycja, w której można dodać nową zawartość bez przerywania żadnych reguł semantycznych dla skojarzonej zawartości. W praktyce pozycja wstawiania znajduje się w dowolnym miejscu zawartości, w której daszek może być umieszczony. Przykładem prawidłowej TextPointer pozycji, która nie jest pozycją wstawiania, jest pozycja między dwoma sąsiednimi Paragraph tagami (czyli między tagiem zamykającym poprzedniego akapitu a tagiem otwierającym następnego akapitu).

Dotyczy

Zobacz też