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


C# ITextPointer.MoveToElementEdge方法代码示例

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


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

示例1: PlainConvertParagraphEnd

        // Part of plain text converter: called from GetTextInternal when processing ElementEnd for Paragraph elements. 
        // Outputs \n - for regular paragraphs and TableRow ends or \t for TableCell ends.
        private static void PlainConvertParagraphEnd(StringBuilder textBuffer, ITextPointer navigator)
        {
            // Check for a special case for a single paragraph within a TableCell 
            // which must be serialized as "\t" character.
            navigator.MoveToElementEdge(ElementEdge.BeforeStart); 
            bool theParagraphIsTheFirstInCollection = navigator.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.ElementStart; 
            navigator.MoveToNextContextPosition(LogicalDirection.Forward);
            navigator.MoveToElementEdge(ElementEdge.AfterEnd); 
            TextPointerContext symbolType = navigator.GetPointerContext(LogicalDirection.Forward);

            if (theParagraphIsTheFirstInCollection && symbolType == TextPointerContext.ElementEnd &&
                typeof(TableCell).IsAssignableFrom(navigator.ParentType)) 
            {
                // This is an end of a table cell 
 
                navigator.MoveToNextContextPosition(LogicalDirection.Forward);
                symbolType = navigator.GetPointerContext(LogicalDirection.Forward); 
                if (symbolType == TextPointerContext.ElementStart)
                {
                    // Next table cell starts after this one. Use '\t' as a cell separator
                    textBuffer.Append('\t'); 
                }
                else 
                { 
                    // This was the last cell in a row. Use '\r\n' as a line separator
                    textBuffer.Append(Environment.NewLine); 
                }
            }
            else
            { 
                // Ordinary paragraph end
                textBuffer.Append(Environment.NewLine); 
            } 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:36,代码来源:TextRangeBase.cs

示例2: GetAutomationPeersFromRange

        //-------------------------------------------------------------------
        // 
        //  Internal Methods 
        //
        //------------------------------------------------------------------- 

        #region Internal Methods

        /// <summary> 
        /// Retrieves a collection of AutomationPeers that fall within the range.
        /// Children that overlap with the range but are not entirely enclosed by 
        /// it will also be included in the collection. 
        /// </summary>
        internal static List<AutomationPeer> GetAutomationPeersFromRange(ITextPointer start, ITextPointer end, ITextPointer ownerContentStart) 
        {
            bool positionMoved;
            AutomationPeer peer = null;
            object element; 
            List<AutomationPeer> peers = new List<AutomationPeer>();
            start = start.CreatePointer(); 
 
            while (start.CompareTo(end) < 0)
            { 
                // Indicate that 'start' position is not moved yet.
                positionMoved = false;

                if (start.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementStart) 
                {
                    // Get adjacent element and try to retrive AutomationPeer for it. 
                    element = start.GetAdjacentElement(LogicalDirection.Forward); 
                    if (element is ContentElement)
                    { 
                        peer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)element);
                        // If AutomationPeer has been retrieved, add it to the collection.
                        // And skip entire element.
                        if (peer != null) 
                        {
                            if (ownerContentStart == null || IsImmediateAutomationChild(start, ownerContentStart)) 
                            { 
                                peers.Add(peer);
                            } 
                            start.MoveToNextContextPosition(LogicalDirection.Forward);
                            start.MoveToElementEdge(ElementEdge.AfterEnd);
                            positionMoved = true;
                        } 
                    }
                } 
                else if (start.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.EmbeddedElement) 
                {
                    // Get adjacent element and try to retrive AutomationPeer for it. 
                    element = start.GetAdjacentElement(LogicalDirection.Forward);
                    if (element is UIElement)
                    {
                        if (ownerContentStart == null || IsImmediateAutomationChild(start, ownerContentStart)) 
                        {
                            peer = UIElementAutomationPeer.CreatePeerForElement((UIElement)element); 
                            // If AutomationPeer has been retrieved, add it to the collection. 
                            if (peer != null)
                            { 
                                peers.Add(peer);
                            }
                            else
                            { 
                                iterate((Visual)element, peers);
                            } 
                        } 
                    }
                    else if (element is ContentElement) 
                    {
                        peer = ContentElementAutomationPeer.CreatePeerForElement((ContentElement)element);
                        // If AutomationPeer has been retrieved, add it to the collection.
                        if (peer != null) 
                        {
                            if (ownerContentStart == null || IsImmediateAutomationChild(start, ownerContentStart)) 
                            { 
                                peers.Add(peer);
                            } 
                        }
                    }
                }
                // Move to the next content position, if position has not been moved already. 
                if (!positionMoved)
                { 
                    if (!start.MoveToNextContextPosition(LogicalDirection.Forward)) 
                    {
                        break; 
                    }
                }
            }
 
            return peers;
        } 
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:92,代码来源:TextContainerHelper.cs


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