本文整理汇总了C#中ITextView.GetPositionAtNextLine方法的典型用法代码示例。如果您正苦于以下问题:C# ITextView.GetPositionAtNextLine方法的具体用法?C# ITextView.GetPositionAtNextLine怎么用?C# ITextView.GetPositionAtNextLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextView
的用法示例。
在下文中一共展示了ITextView.GetPositionAtNextLine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPositionAtPageBoundary
/// <summary>
/// Retrieves position at the page boundary from given suggestedX.
/// </summary>
/// <param name="pageTop">Whether asking for top of the page or bottom of the page.</param>
/// <param name="pageTextView">TextView representing the page.</param>
/// <param name="position">Position at the beginning/end of the page.</param>
/// <param name="suggestedX">Suggested offset in the page.</param>
/// <returns>Position at the page boundary from given suggestedX.</returns>
private ITextPointer GetPositionAtPageBoundary(bool pageTop, ITextView pageTextView, ITextPointer position, double suggestedX)
{
double newSuggestedX;
int newLinesMoved;
ITextPointer positionOut;
// If moving to the first/last line of the next/previous TextView, there is
// special handling needed to position at the right suggestedX. Otherwise, TextView
// will return the same position.
if (pageTop)
{
// Move line down and line up.
positionOut = pageTextView.GetPositionAtNextLine(position, suggestedX, 1, out newSuggestedX, out newLinesMoved);
if (newLinesMoved == 1)
{
positionOut = pageTextView.GetPositionAtNextLine(positionOut, newSuggestedX, -1, out newSuggestedX, out newLinesMoved);
}
else
{
// Line down failed, so use the first position of TextView.
positionOut = position;
}
}
else
{
// Move line up and line down.
positionOut = pageTextView.GetPositionAtNextLine(position, suggestedX, -1, out newSuggestedX, out newLinesMoved);
if (newLinesMoved == -1)
{
positionOut = pageTextView.GetPositionAtNextLine(positionOut, newSuggestedX, 1, out newSuggestedX, out newLinesMoved);
}
else
{
// Line up failed, so use the last position of TextView.
positionOut = position;
}
}
return positionOut;
}
示例2: MoveToLineBoundary
// <see cref="System.Windows.Documents.TextPointer.MoveToLineBoundary"/>
internal static int MoveToLineBoundary(ITextPointer thisPointer, ITextView textView, int count, bool respectNonMeargeableInlineStart)
{
ITextPointer position;
double newSuggestedX;
Invariant.Assert(!thisPointer.IsFrozen, "Can't reposition a frozen pointer!");
Invariant.Assert(textView != null, "Null TextView!"); // Did you check ITextPointer.HasValidLayout?
position = textView.GetPositionAtNextLine(thisPointer, Double.NaN, count, out newSuggestedX, out count);
if (!position.IsAtInsertionPosition)
{
if (!respectNonMeargeableInlineStart ||
(!IsAtNonMergeableInlineStart(position) && !IsAtNonMergeableInlineEnd(position)))
{
position.MoveToInsertionPosition(position.LogicalDirection);
}
}
if (IsAtRowEnd(position))
{
// We will find outselves at a row end when we have incomplete
// markup like
//
// <TableCell></TableCell> <!-- No inner Run! -->
//
// In that case the end-of-row is the entire line.
thisPointer.MoveToPosition(position);
thisPointer.SetLogicalDirection(position.LogicalDirection);
}
else
{
TextSegment lineRange = textView.GetLineRange(position);
if (!lineRange.IsNull)
{
thisPointer.MoveToPosition(lineRange.Start);
thisPointer.SetLogicalDirection(lineRange.Start.LogicalDirection);
}
else if (count > 0)
{
// It is possible to get a non-zero return value from ITextView.GetPositionAtNextLine
// when moving into a BlockUIContainer. The container is the "next line" but does
// not contain any lines itself -- GetLineRange will return null.
thisPointer.MoveToPosition(position);
thisPointer.SetLogicalDirection(position.LogicalDirection);
}
}
return count;
}