本文整理汇总了C#中ITextView.GetLineRange方法的典型用法代码示例。如果您正苦于以下问题:C# ITextView.GetLineRange方法的具体用法?C# ITextView.GetLineRange怎么用?C# ITextView.GetLineRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITextView
的用法示例。
在下文中一共展示了ITextView.GetLineRange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsAtLineWrappingPosition
/// <summary>
/// Checks if line wrapping is happening at this position
/// </summary>
internal static bool IsAtLineWrappingPosition(ITextPointer position, ITextView textView)
{
Invariant.Assert(position != null, "null check: position");
if (!position.HasValidLayout)
{
return false;
}
Invariant.Assert(textView != null, "textView cannot be null because the position has valid layout");
TextSegment lineSegment = textView.GetLineRange(position);
if (lineSegment.IsNull)
{
return false;
}
bool isAtLineWrappingPosition = position.LogicalDirection == LogicalDirection.Forward
? position.CompareTo(lineSegment.Start) == 0
: position.CompareTo(lineSegment.End) == 0;
return isAtLineWrappingPosition;
}
示例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;
}
示例3: GetNormalizedLineRange
// Returns a normalized line range from TextView for a given position.
// Note: In current contract, line range returned by TextView.GetLineRange() is not guaranteed to be normalized.
// This helper does appropriate correction and returns a normalized line range.
internal static TextSegment GetNormalizedLineRange(ITextView textView, ITextPointer position)
{
TextSegment lineRange = textView.GetLineRange(position);
if (lineRange.IsNull)
{
if (!typeof(BlockUIContainer).IsAssignableFrom(position.ParentType))
{
return lineRange;
}
ITextPointer lineStart = position.CreatePointer(LogicalDirection.Forward);
lineStart.MoveToElementEdge(ElementEdge.AfterStart);
ITextPointer lineEnd = position.CreatePointer(LogicalDirection.Backward);
lineEnd.MoveToElementEdge(ElementEdge.BeforeEnd);
lineRange = new TextSegment(lineStart, lineEnd);
return lineRange;
}
// Normalize line range
ITextRange textRange = new TextRange(lineRange.Start, lineRange.End);
return new TextSegment(textRange.Start, textRange.End);
}