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


C# ITextPointer.GetFormatNormalizedPosition方法代码示例

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


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

示例1: Contains

        //----------------------------------------------------- 
        //
        // ITextRange Methods
        //
        //----------------------------------------------------- 

        #region ITextRange Methods 
 
        //......................................................
        // 
        // Selection Building
        //
        //......................................................
 
        /// <summary>
        /// </summary> 
        // 
        internal static bool Contains(ITextRange thisRange, ITextPointer textPointer)
        { 
            NormalizeRange(thisRange);

            if (textPointer == null)
            { 
                throw new ArgumentNullException("textPointer");
            } 
 
            if (textPointer.TextContainer != thisRange.Start.TextContainer)
            { 
                throw new ArgumentException(SR.Get(SRID.NotInAssociatedTree), "textPointer");
            }

            // Correct position normalization on range boundary so that 
            // our test would not depend on what side of formatting tags
            // pointer is located. 
            if (textPointer.CompareTo(thisRange.Start) < 0) 
            {
                textPointer = textPointer.GetFormatNormalizedPosition(LogicalDirection.Forward); 
            }
            else if (textPointer.CompareTo(thisRange.End) > 0)
            {
                textPointer = textPointer.GetFormatNormalizedPosition(LogicalDirection.Backward); 
            }
 
            // Check if at least one segment contains this position. 
            for (int i = 0; i < thisRange._TextSegments.Count; i++)
            { 
                if (thisRange._TextSegments[i].Contains(textPointer))
                {
                    return true;
                } 
            }
 
            return false; 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:54,代码来源:TextRangeBase.cs

示例2: GetNormalizedRange

        // Normalizes a range:
        //
        // -The start position is advanced over all element edges not visible
        //  to the IMEs.
        // -Start and end positions are moved to insertion positions.
        private void GetNormalizedRange(int startCharOffset, int endCharOffset, out ITextPointer start, out ITextPointer end)
        {
            start = CreatePointerAtCharOffset(startCharOffset, LogicalDirection.Forward);
            end = (startCharOffset == endCharOffset) ? start : CreatePointerAtCharOffset(endCharOffset, LogicalDirection.Backward);

            // Skip over hidden element edges.
            while (start.CompareTo(end) < 0)
            {
                TextPointerContext forwardContext = start.GetPointerContext(LogicalDirection.Forward);

                if (forwardContext == TextPointerContext.ElementStart)
                {
                    TextElement element = start.GetAdjacentElement(LogicalDirection.Forward) as TextElement;

                    if (element == null)
                        break;
                    if (element.IMELeftEdgeCharCount != 0)
                        break;
                }
                else if (forwardContext != TextPointerContext.ElementEnd)
                {
                    break;
                }

                start.MoveToNextContextPosition(LogicalDirection.Forward);
            }

            // Move to insertion positions.
            // If the positions are already adjacent to text, we must respect
            // the IME's decision in regards to exact placement.
            // MoveToInsertionPosition will skip over surrogates and combining
            // marks, but the IME needs fine-grained control over these positions.

            if (start.CompareTo(end) == 0)
            {
                start = start.GetFormatNormalizedPosition(LogicalDirection.Backward);
                end = start;
            }
            else
            {
                start = start.GetFormatNormalizedPosition(LogicalDirection.Backward);
                end = end.GetFormatNormalizedPosition(LogicalDirection.Backward);
            }
        }
开发者ID:mind0n,项目名称:hive,代码行数:49,代码来源:TextStore.cs

示例3: GetNormalizedPosition

        private static ITextPointer GetNormalizedPosition(ITextRange thisRange, ITextPointer position, LogicalDirection direction) 
        {
            ITextPointer normalizedPosition;

            if (thisRange.IgnoreTextUnitBoundaries) 
            {
                normalizedPosition = position.GetFormatNormalizedPosition(direction); 
            } 
            else
            { 
                normalizedPosition = position.GetInsertionPosition(direction);
            }

            return normalizedPosition; 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:15,代码来源:TextRangeBase.cs


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