本文整理汇总了C#中System.Windows.Documents.TextPointer.SetLogicalDirection方法的典型用法代码示例。如果您正苦于以下问题:C# TextPointer.SetLogicalDirection方法的具体用法?C# TextPointer.SetLogicalDirection怎么用?C# TextPointer.SetLogicalDirection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.TextPointer
的用法示例。
在下文中一共展示了TextPointer.SetLogicalDirection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLineStartPosition
/// <summary>
/// Returns a TextPointer at the start of line after skipping
/// a given number of line starts in forward or backward direction.
/// </summary>
/// <param name="count">
/// Offset of the destination line. Negative values specify preceding
/// lines, zero specifies the current line, positive values specify
/// following lines.
/// </param>
/// <param name="actualCount">
/// The offset of the line moved to. This value may be less than
/// requested if the beginning or end of document is encountered.
/// </param>
/// <returns>
/// TextPointer positioned at the begining of a line requested
/// (with LogicalDirection set to Forward).
/// If there is no sufficient lines in requested direction,
/// returns a position at the beginning of a farthest line
/// in this direction. In such case out parameter actualCount
/// gets a number of lines actually skipped.
/// Unlike the other override in this case the returned pointer is never null.
/// </returns>
/// <remarks>
/// If this TextPointer is at an otherwise ambiguous position, exactly
/// between two lines, the LogicalDirection property is used to determine
/// current position. So a TextPointer with backward LogicalDirection
/// is considered to be at the end of line, and calling MoveToLineBoundary(0)
/// would reposition it at the start of the preceding line. Making the
/// same call with forward LogicalDirection would leave the TextPointer
/// positioned where it started -- at the start of the following line.
/// </remarks>
public TextPointer GetLineStartPosition(int count, out int actualCount)
{
this.ValidateLayout();
TextPointer position = new TextPointer(this);
if (this.HasValidLayout)
{
actualCount = position.MoveToLineBoundary(count);
}
else
{
actualCount = 0;
}
position.SetLogicalDirection(LogicalDirection.Forward);
position.Freeze();
return position;
}