TextPointer.GetPositionAtOffset Yöntem
Tanım
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
belirtilen uzaklık tarafından belirtilen konuma, içeriğin başından itibaren simgelerde bir TextPointer döndürür.
Aşırı Yüklemeler
| Name | Description |
|---|---|
| GetPositionAtOffset(Int32, LogicalDirection) |
Belirtilen uzaklık tarafından belirtilen konuma, geçerli TextPointer başından ve belirtilen yönde semboller halinde bir TextPointer döndürür. |
| GetPositionAtOffset(Int32) |
Geçerli TextPointerbaşından itibaren belirtilen uzaklık tarafından belirtilen konuma, sembollerde bir TextPointer döndürür. |
GetPositionAtOffset(Int32, LogicalDirection)
Belirtilen uzaklık tarafından belirtilen konuma, geçerli TextPointer başından ve belirtilen yönde semboller halinde bir TextPointer döndürür.
public:
System::Windows::Documents::TextPointer ^ GetPositionAtOffset(int offset, System::Windows::Documents::LogicalDirection direction);
public System.Windows.Documents.TextPointer GetPositionAtOffset(int offset, System.Windows.Documents.LogicalDirection direction);
member this.GetPositionAtOffset : int * System.Windows.Documents.LogicalDirection -> System.Windows.Documents.TextPointer
Public Function GetPositionAtOffset (offset As Integer, direction As LogicalDirection) As TextPointer
Parametreler
- offset
- Int32
Konumu hesaplamak ve döndürmek için simgelerdeki bir uzaklık. Uzaklık negatifse, döndürülen TextPointer geçerli TextPointerdeğerden önce olur; aksi takdirde, bunu izler.
- direction
- LogicalDirection
Döndürülen LogicalDirectionöğesinin TextPointer mantıksal yönünü belirten değerlerden biri.
Döndürülenler
Belirtilen TextPointer uzaklık tarafından belirtilen konuma veya null uzaklık içeriğin sonunu aşıyorsa A.
Açıklamalar
Aşağıdakilerden herhangi biri simge olarak kabul edilir:
öğesi için TextElement bir açma veya kapatma etiketi.
UIElement veya InlineUIContaineriçinde bulunan bir BlockUIContainer öğe. Bu tür bir UIElement her zaman tam olarak bir simge olarak sayılır; UIElement içerdiği ek içerik veya öğeler simge olarak sayılmaz.
Metin öğesinin Run içinde 16 bit Unicode karakteri.
Ayrıca bkz.
Şunlara uygulanır
GetPositionAtOffset(Int32)
Geçerli TextPointerbaşından itibaren belirtilen uzaklık tarafından belirtilen konuma, sembollerde bir TextPointer döndürür.
public:
System::Windows::Documents::TextPointer ^ GetPositionAtOffset(int offset);
public System.Windows.Documents.TextPointer GetPositionAtOffset(int offset);
member this.GetPositionAtOffset : int -> System.Windows.Documents.TextPointer
Public Function GetPositionAtOffset (offset As Integer) As TextPointer
Parametreler
- offset
- Int32
Konumu hesaplamak ve döndürmek için simgelerdeki bir uzaklık. Uzaklık negatifse, konum, özelliği tarafından LogicalDirection belirtilenin karşısındaki mantıksal yönde hesaplanır.
Döndürülenler
TextPointer Belirtilen uzaklık tarafından belirtilen konuma bir veya null karşılık gelen konum bulunamıyorsa.
Örnekler
Aşağıdaki örnekte bu yöntem için bir kullanım gösterilmektedir. Örnek, bir yöntem çifti uygulamak için yöntemini, herhangi bir barındırma paragrafı ile ilgili olarak belirtilen konuma uzaklığı hesaplamak için yöntemini, diğerini ise belirtilen paragrafta belirtilen uzaklıkta döndürmek GetPositionAtOffset için kullanırTextPointer.
// Returns the offset for the specified position relative to any containing paragraph.
int GetOffsetRelativeToParagraph(TextPointer position)
{
// Adjust the pointer to the closest forward insertion position, and look for any
// containing paragraph.
Paragraph paragraph = (position.GetInsertionPosition(LogicalDirection.Forward)).Paragraph;
// Some positions may be not within any Paragraph;
// this method returns an offset of -1 to indicate this condition.
return (paragraph == null) ? -1 : paragraph.ContentStart.GetOffsetToPosition(position);
}
// Returns a TextPointer to a specified offset into a specified paragraph.
TextPointer GetTextPointerRelativeToParagraph(Paragraph paragraph, int offsetRelativeToParagraph)
{
// Verify that the specified offset falls within the specified paragraph. If the offset is
// past the end of the paragraph, return a pointer to the farthest offset position in the paragraph.
// Otherwise, return a TextPointer to the specified offset in the specified paragraph.
return (offsetRelativeToParagraph > paragraph.ContentStart.GetOffsetToPosition(paragraph.ContentEnd))
? paragraph.ContentEnd : paragraph.ContentStart.GetPositionAtOffset(offsetRelativeToParagraph);
}
' Returns the offset for the specified position relative to any containing paragraph.
Private Function GetOffsetRelativeToParagraph(ByVal position As TextPointer) As Integer
' Adjust the pointer to the closest forward insertion position, and look for any
' containing paragraph.
Dim paragraph As Paragraph = (position.GetInsertionPosition(LogicalDirection.Forward)).Paragraph
' Some positions may be not within any Paragraph
' this method returns an offset of -1 to indicate this condition.
Return If((paragraph Is Nothing), -1, paragraph.ContentStart.GetOffsetToPosition(position))
End Function
' Returns a TextPointer to a specified offset into a specified paragraph.
Private Function GetTextPointerRelativeToParagraph(ByVal paragraph As Paragraph, ByVal offsetRelativeToParagraph As Integer) As TextPointer
' Verify that the specified offset falls within the specified paragraph. If the offset is
' past the end of the paragraph, return a pointer to the farthest offset position in the paragraph.
' Otherwise, return a TextPointer to the specified offset in the specified paragraph.
Return If((offsetRelativeToParagraph > paragraph.ContentStart.GetOffsetToPosition(paragraph.ContentEnd)), paragraph.ContentEnd, paragraph.ContentStart.GetPositionAtOffset(offsetRelativeToParagraph))
End Function
Açıklamalar
Aşağıdakilerden herhangi biri simge olarak kabul edilir:
öğesi için TextElement bir açma veya kapatma etiketi.
UIElement veya InlineUIContaineriçinde bulunan bir BlockUIContainer öğe. Bu tür bir UIElement her zaman tam olarak bir simge olarak sayılır; UIElement içerdiği ek içerik veya öğeler simge olarak sayılmaz.
Metin öğesinin Run içinde 16 bit Unicode karakteri.