本文整理匯總了C#中System.Windows.Documents.TextElement.Reposition方法的典型用法代碼示例。如果您正苦於以下問題:C# TextElement.Reposition方法的具體用法?C# TextElement.Reposition怎麽用?C# TextElement.Reposition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Documents.TextElement
的用法示例。
在下文中一共展示了TextElement.Reposition方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: PasteMergeableTextFragment
// Helper for PasteTextFragment
private static void PasteMergeableTextFragment(TextElement fragment, TextRange range, TextPointer insertionPosition)
{
TextPointer fragmentStart;
TextPointer fragmentEnd;
if (fragment is Span)
{
// Split structure at insertion point in target
insertionPosition = TextRangeEdit.SplitFormattingElements(insertionPosition, /*keepEmptyFormatting:*/false);
Invariant.Assert(insertionPosition.Parent is Paragraph, "insertionPosition must be in a scope of a Paragraph after splitting formatting elements");
// Move the whole Span into the insertion point
fragment.RepositionWithContent(insertionPosition);
// Store edge positions of inserted content
fragmentStart = fragment.ElementStart;
fragmentEnd = fragment.ElementEnd;
// Remove wrapper from a tree
fragment.Reposition(null, null);
ValidateMergingPositions(typeof(Inline), fragmentStart, fragmentEnd);
// Transfer inheritable contextual properties
ApplyContextualProperties(fragmentStart, fragmentEnd, fragment);
}
else
{
// Correct leading nested List elements in the fragment
CorrectLeadingNestedLists((Section)fragment);
// Split a paragraph at insertion position
bool needFirstParagraphMerging = SplitParagraphForPasting(ref insertionPosition);
// Move the whole Section into the insertion point
fragment.RepositionWithContent(insertionPosition);
// Store edge positions of inserted content
fragmentStart = fragment.ElementStart;
fragmentEnd = fragment.ElementEnd.GetPositionAtOffset(0, LogicalDirection.Forward); // need forward orientation to stick with the following content during merge at fragmentStart position
// And unwrap the root Section
fragment.Reposition(null, null);
ValidateMergingPositions(typeof(Block), fragmentStart, fragmentEnd);
// Transfer inheritable contextual properties
ApplyContextualProperties(fragmentStart, fragmentEnd, fragment);
// Merge paragraphs on fragment boundaries
if (needFirstParagraphMerging)
{
MergeParagraphsAtPosition(fragmentStart, /*mergingOnFragmentStart:*/true);
}
// Get an indication that we need to merge last paragraph
if (!((Section)fragment).HasTrailingParagraphBreakOnPaste)
{
MergeParagraphsAtPosition(fragmentEnd, /*mergingOnFragmentStart:*/false);
}
}
//
// For paragraph pasting move range end to the following paragraph, because
// it must include an ending paragraph break (in case of no-merging)
if (fragment is Section && ((Section)fragment).HasTrailingParagraphBreakOnPaste)
{
fragmentEnd = fragmentEnd.GetInsertionPosition(LogicalDirection.Forward);
}
// Select pasted content
range.Select(fragmentStart, fragmentEnd);
}