当前位置: 首页>>代码示例>>C#>>正文


C# ITextView.GetLineRange方法代码示例

本文整理汇总了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;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:26,代码来源:TextPointerBase.cs

示例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;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:52,代码来源:TextPointerBase.cs

示例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);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:25,代码来源:TextEditorSelection.cs


注:本文中的ITextView.GetLineRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。