TextPointer.GetNextInsertionPosition(LogicalDirection) Metoda

Definice

TextPointer Vrátí hodnotu na další pozici vložení v zadaném logickém směru.

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

Jedna z LogicalDirection hodnot, která určuje logický směr, ve kterém se má hledat další pozice vložení.

Návraty

TextPointer

A TextPointer , která identifikuje další pozici vložení v požadovaném směru, nebo null pokud nelze najít žádnou další pozici vložení.

Příklady

Následující příklad ukazuje použití pro tuto metodu. Příklad používá metodu GetNextInsertionPosition k procházení hranic prvků obsahu, aby se spočítal počet Paragraph prvků, které jsou přítomné mezi dvěma zadanými TextPointer instancemi.

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

Poznámky

Pozice vložení je pozice, kde je možné přidat nový obsah, aniž by došlo k porušení sémantických pravidel přidruženého obsahu. V praxi je pozice vložení kdekoli v obsahu, kde může být umístěn kurzor. Příkladem platné TextPointer pozice, která není pozice vložení, je pozice mezi dvěma sousedními Paragraph značkami (to znamená mezi pravou značkou předchozího odstavce a levou značkou dalšího odstavce).

Platí pro

Viz také