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


C# StaticTextPointer.CompareTo方法代码示例

本文整理汇总了C#中System.Windows.Documents.StaticTextPointer.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# StaticTextPointer.CompareTo方法的具体用法?C# StaticTextPointer.CompareTo怎么用?C# StaticTextPointer.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Documents.StaticTextPointer的用法示例。


在下文中一共展示了StaticTextPointer.CompareTo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetNextChangePosition

        // Returns the position of the next highlight start or end in an
        // indicated direction, or null if there is no such position.
        internal override StaticTextPointer GetNextChangePosition(StaticTextPointer textPosition, LogicalDirection direction)
        {
            StaticTextPointer transitionPosition;

            transitionPosition = StaticTextPointer.Null;

            if (!IsTextRangeEmpty(_selection) && !_selection.IsInterimSelection)
            {
                int segmentCount;
                List<TextSegment> textSegments = _selection.TextSegments;
                TextSegment textSegment;

                segmentCount = textSegments.Count;

                if (direction == LogicalDirection.Forward)
                {
                    for (int segmentIndex = 0; segmentIndex < segmentCount; segmentIndex++)
                    {
                        textSegment = textSegments[segmentIndex];

                        // Ignore empty segments.
                        // 












                        if (textSegment.Start.CompareTo(textSegment.End) != 0)
                        {
                            if (textPosition.CompareTo(textSegment.Start) < 0)
                            {
                                transitionPosition = textSegment.Start.CreateStaticPointer();
                                break;
                            }
                            else if (textPosition.CompareTo(textSegment.End) < 0)
                            {
                                transitionPosition = textSegment.End.CreateStaticPointer();
                                break;
                            }
                        }
                    }
                }
                else
                {
                    for (int segmentIndex = segmentCount - 1; segmentIndex >= 0; segmentIndex--)
                    {
                        textSegment = textSegments[segmentIndex];

                        if (textSegment.Start.CompareTo(textSegment.End) != 0)
                        {
                            if (textPosition.CompareTo(textSegment.End) > 0)
                            {
                                transitionPosition = textSegment.End.CreateStaticPointer();
                                break;
                            }
                            else if (textPosition.CompareTo(textSegment.Start) > 0)
                            {
                                transitionPosition = textSegment.Start.CreateStaticPointer();
                                break;
                            }
                        }
                    }
                }
            }

            return transitionPosition;
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:76,代码来源:TextSelectionHighlightLayer.cs

示例2: IsContentHighlighted

        // Returns true iff the indicated content has scoping highlights.
        internal override bool IsContentHighlighted(StaticTextPointer textPosition, LogicalDirection direction)
        {
            int segmentCount;
            TextSegment textSegment;

            // No highlight when the selection is for interim character.
            if (_selection.IsInterimSelection)
            {
                return false;
            }

            // Check all segments of selection
            List<TextSegment> textSegments = _selection.TextSegments;
            segmentCount = textSegments.Count;
            for (int segmentIndex = 0; segmentIndex < segmentCount; segmentIndex++)
            {
                textSegment = textSegments[segmentIndex];

                if ((direction == LogicalDirection.Forward && textSegment.Start.CompareTo(textPosition) <= 0 && textPosition.CompareTo(textSegment.End) < 0) || //
                    (direction == LogicalDirection.Backward && textSegment.Start.CompareTo(textPosition) < 0 && textPosition.CompareTo(textSegment.End) <= 0))
                {
                    return true;
                }

            }
            return false;
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:28,代码来源:TextSelectionHighlightLayer.cs

示例3: GetNextErrorTransition

        // Returns the position of the next error start or end in an
        // indicated direction, or null if there is no such position.
        // Called by the SpellerHighlightLayer.
        internal StaticTextPointer GetNextErrorTransition(StaticTextPointer textPosition, LogicalDirection direction)
        {
            StaticTextPointer transitionPosition;
            int index;
            int i;

            transitionPosition = StaticTextPointer.Null;

            index = FindIndex(textPosition, direction);

            if (index == -1)
            {
                // textPosition is at the document edge.
                // leave transitionPosition null.
            }
            else if (direction == LogicalDirection.Forward)
            {
                if (IsErrorRun(index))
                {
                    transitionPosition = GetRunEndPosition(index);
                }
                else
                {
                    for (i = index+1; i < _runList.Count; i++)
                    {
                        if (IsErrorRun(i))
                        {
                            transitionPosition = GetRun(i).Position.CreateStaticPointer();
                            break;
                        }
                    }
                }
            }
            else // direction == LogicalDirection.Backward
            {
                if (IsErrorRun(index))
                {
                    transitionPosition = GetRun(index).Position.CreateStaticPointer();
                }
                else
                {
                    for (i = index - 1; i > 0; i--)
                    {
                        if (IsErrorRun(i))
                        {
                            transitionPosition = GetRunEndPosition(i);
                            break;
                        }
                    }
                }
            }

            // If we ever had two consecuative errors (with touching borders)
            // we could return a transitionPosition == textPosition, which is illegal.
            // We rely on the fact that consecutive errors are always separated
            // by a word break to avoid this.
            // 
            Invariant.Assert(transitionPosition.IsNull || textPosition.CompareTo(transitionPosition) != 0);

            return transitionPosition;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:64,代码来源:SpellerStatusTable.cs

示例4: FindIndex

        // Finds the index of a run containing the specified content.
        // Returns -1 if there is no run in the indicated direction -- when
        // position is at the document edge pointing to nothing.
        private int FindIndex(StaticTextPointer position, LogicalDirection direction)
        {
            Run run;
            int index;
            int minIndex;
            int maxIndex;

            index = -1;
            minIndex = 0;
            maxIndex = _runList.Count;

            while (minIndex < maxIndex)
            {
                index = (minIndex + maxIndex) / 2;

                run = GetRun(index);

                if (direction == LogicalDirection.Forward && position.CompareTo(run.Position) < 0 ||
                    direction == LogicalDirection.Backward && position.CompareTo(run.Position) <= 0)
                {
                    // Search to the left.
                    maxIndex = index;
                }
                else if (direction == LogicalDirection.Forward && position.CompareTo(GetRunEndPosition(index)) >= 0 ||
                         direction == LogicalDirection.Backward && position.CompareTo(GetRunEndPosition(index)) > 0)
                {
                    // Search to the right.
                    minIndex = index + 1;
                }
                else
                {
                    // Got a match.
                    break;
                }
            }

            if (minIndex >= maxIndex)
            {
                // We walked off the document edge searching.
                // position is at document start or end, and direction
                // points off into space, so there's no associated run.
                index = -1;
            }

            return index;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:49,代码来源:SpellerStatusTable.cs

示例5: GetNextBackwardPosition

        /// <summary>
        /// Gets next change position in the backward direction 
        /// </summary>
        /// <param name="pos"> start position</param> 
        /// <returns>nex position if any</returns> 
        private ITextPointer GetNextBackwardPosition(StaticTextPointer pos)
        { 
            for (int i = _segments.Count - 1; i >= 0; i--)
            {
                HighlightSegment highlightSegment = _segments[i];
                if (pos.CompareTo(highlightSegment.Segment.End) <= 0) 
                {
                    if (pos.CompareTo(highlightSegment.Segment.Start) > 0) 
                        return highlightSegment.Segment.Start; 
                }
                else 
                {
                    return highlightSegment.Segment.End;
                }
            } 

            return null; 
 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:24,代码来源:AnnotationHighlightLayer.cs

示例6: GetNextForwardPosition

        /// <summary>
        /// Gets next change position in the forward direction 
        /// </summary> 
        /// <param name="pos"> start position</param>
        /// <returns>next position if any</returns> 
        private ITextPointer GetNextForwardPosition(StaticTextPointer pos)
        {
            for (int i = 0; i < _segments.Count; i++)
            { 
                HighlightSegment highlightSegment = _segments[i];
                if (pos.CompareTo(highlightSegment.Segment.Start) >= 0) 
                { 
                    if (pos.CompareTo(highlightSegment.Segment.End) < 0)
                        return highlightSegment.Segment.End; 
                }
                else
                {
                    return highlightSegment.Segment.Start; 
                }
            } 
 
            return null;
 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:24,代码来源:AnnotationHighlightLayer.cs

示例7: GetNextChangePosition

        // Returns the position of the next highlight start or end in an
        // indicated direction, or null if there is no such position.
        internal override StaticTextPointer GetNextChangePosition(StaticTextPointer textPosition, LogicalDirection direction)
        {
            StaticTextPointer transitionPosition;
            AttributeRange attributeRange;
            int i;

            transitionPosition = StaticTextPointer.Null;

            // Use a simple iterative search since we don't ever have
            // more than a handful of attributes in a composition.

            if (direction == LogicalDirection.Forward)
            {
                for (i = 0; i < _attributeRanges.Count; i++)
                {
                    attributeRange = (AttributeRange)_attributeRanges[i];

                    if (attributeRange.Start.CompareTo(attributeRange.End) != 0)
                    {
                        if (textPosition.CompareTo(attributeRange.Start) < 0)
                        {
                            transitionPosition = attributeRange.Start.CreateStaticPointer();
                            break;
                        }
                        else if (textPosition.CompareTo(attributeRange.End) < 0)
                        {
                            transitionPosition = attributeRange.End.CreateStaticPointer();
                            break;
                        }
                    }
                }
            }
            else
            {
                for (i = _attributeRanges.Count - 1; i >= 0; i--)
                {
                    attributeRange = (AttributeRange)_attributeRanges[i];

                    if (attributeRange.Start.CompareTo(attributeRange.End) != 0)
                    {
                        if (textPosition.CompareTo(attributeRange.End) > 0)
                        {
                            transitionPosition = attributeRange.End.CreateStaticPointer();
                            break;
                        }
                        else if (textPosition.CompareTo(attributeRange.Start) > 0)
                        {
                            transitionPosition = attributeRange.Start.CreateStaticPointer();
                            break;
                        }
                    }
                }
            }

            return transitionPosition;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:58,代码来源:DisplayAttributeHighlightLayer.cs

示例8: GetRangeAtPosition

        // Returns the AttributeRange covering specified content, or null
        // if no such range exists.
        private AttributeRange GetRangeAtPosition(StaticTextPointer textPosition, LogicalDirection direction)
        {
            int i;
            AttributeRange attributeRange;
            AttributeRange attributeRangeAtPosition;

            // Use a simple iterative search since we don't ever have
            // more than a handful of attributes in a composition.

            attributeRangeAtPosition = null;

            if (direction == LogicalDirection.Forward)
            {
                for (i = 0; i < _attributeRanges.Count; i++)
                {
                    attributeRange = (AttributeRange)_attributeRanges[i];

                    if (attributeRange.Start.CompareTo(attributeRange.End) != 0)
                    {
                        if (textPosition.CompareTo(attributeRange.Start) < 0)
                        {
                            break;
                        }
                        else if (textPosition.CompareTo(attributeRange.End) < 0)
                        {
                            attributeRangeAtPosition = attributeRange;
                            break;
                        }
                    }
                }
            }
            else
            {
                for (i = _attributeRanges.Count - 1; i >= 0; i--)
                {
                    attributeRange = (AttributeRange)_attributeRanges[i];

                    if (attributeRange.Start.CompareTo(attributeRange.End) != 0)
                    {
                        if (textPosition.CompareTo(attributeRange.End) > 0)
                        {
                            break;
                        }
                        else if (textPosition.CompareTo(attributeRange.Start) > 0)
                        {
                            attributeRangeAtPosition = attributeRange;
                            break;
                        }
                    }
                }
            }

            return attributeRangeAtPosition;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:56,代码来源:DisplayAttributeHighlightLayer.cs

示例9: Max

        internal static StaticTextPointer Max(StaticTextPointer position1, StaticTextPointer position2)
        {
            position2.AssertGeneration();

            return position1.CompareTo(position2) >= 0 ? position1 : position2;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:6,代码来源:StaticTextPointer.cs


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