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


C# TextPointer.Freeze方法代码示例

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


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

示例1: GetPositionAtOffset

 /// <summary>
 /// Returns a TextPointer at a new position by a specified symbol
 /// count.
 /// </summary>
 /// <param name="offset">
 /// Number of symbols to advance.  offset may be negative, in which
 /// case the TextPointer is moved backwards.
 /// </param>
 /// <param name="direction">
 /// LogicalDirection desired for a returned TextPointer.
 /// </param>
 /// <returns>
 /// TextPointer located at requested position in case if requested position
 /// does exist, otherwize returns null. LogicalDirection of the TextPointer
 /// returned is as specified by a <paramref name="direction"/>.
 /// </returns>
 /// <remarks>
 /// <para>This method, like all other TextPointer methods, defines a symbol
 /// as one of:</para>
 /// <para>- 16 bit Unicode character.</para>
 /// <para>- opening or closing tag of a <see cref="TextElement"/>.</para>
 /// <para>- the whole <see cref="UIElement"/> as atomic embedded object.</para>
 /// <para>See examples in <seealso cref="TextPointer.GetPositionAtOffset(int)"/> method with one parameter.</para>
 /// </remarks>
 public TextPointer GetPositionAtOffset(int offset, LogicalDirection direction)
 {
     TextPointer position = new TextPointer(this, direction);
     int actualCount = position.MoveByOffset(offset);
     if (actualCount == offset)
     {
         position.Freeze();
         return position;
     }
     else
     {
         return null;
     }
 }
开发者ID:mind0n,项目名称:hive,代码行数:38,代码来源:TextPointer.cs

示例2: NotifyTypographicPropertyChanged

        // Notify our TextContainer that a typographic property has changed
        // value on this TextElement.
        // This has the side effect of invalidating layout.
        internal void NotifyTypographicPropertyChanged(bool affectsMeasureOrArrange, bool localValueChanged, DependencyProperty property)
        {
            if (!this.IsInTree) // No work to do if no one's listening.
            {
                return;
            }

            TextContainer tree;
            TextPointer beforeStart;

            tree = EnsureTextContainer();

            // Take note that something layout related has changed.
            tree.NextLayoutGeneration();

            // Notify any external listeners.
            if (tree.HasListeners)
            {
                // Get the position before the start of this element.
                beforeStart = new TextPointer(tree, _textElementNode, ElementEdge.BeforeStart, LogicalDirection.Forward);
                beforeStart.Freeze();

                // Raise ContentAffected event that spans entire TextElement (from BeforeStart to AfterEnd).
                tree.BeginChange();
                try
                {
                    tree.BeforeAddChange();
                    if (localValueChanged)
                    {
                        tree.AddLocalValueChange();
                    }
                    tree.AddChange(beforeStart, _textElementNode.SymbolCount, _textElementNode.IMECharCount,
                        PrecursorTextChangeType.PropertyModified, property, !affectsMeasureOrArrange);
                }
                finally
                {
                    tree.EndChange();
                }
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:43,代码来源:TextElement.cs

示例3: GetLineStartPosition

        /// <summary>
        /// Returns a TextPointer at the start of line after skipping
        /// a given number of line starts in forward or backward direction.
        /// </summary>
        /// <param name="count">
        /// Offset of the destination line.  Negative values specify preceding
        /// lines, zero specifies the current line, positive values specify
        /// following lines.
        /// </param>
        /// <param name="actualCount">
        /// The offset of the line moved to.  This value may be less than
        /// requested if the beginning or end of document is encountered.
        /// </param>
        /// <returns>
        /// TextPointer positioned at the begining of a line requested
        /// (with LogicalDirection set to Forward).
        /// If there is no sufficient lines in requested direction,
        /// returns a position at the beginning of a farthest line
        /// in this direction. In such case out parameter actualCount
        /// gets a number of lines actually skipped.
        /// Unlike the other override in this case the returned pointer is never null.
        /// </returns>
        /// <remarks>
        /// If this TextPointer is at an otherwise ambiguous position, exactly
        /// between two lines, the LogicalDirection property is used to determine
        /// current position.  So a TextPointer with backward LogicalDirection
        /// is considered to be at the end of line, and calling MoveToLineBoundary(0)
        /// would reposition it at the start of the preceding line.  Making the
        /// same call with forward LogicalDirection would leave the TextPointer
        /// positioned where it started -- at the start of the following line.
        /// </remarks>
        public TextPointer GetLineStartPosition(int count, out int actualCount)
        {
            this.ValidateLayout();

            TextPointer position = new TextPointer(this);

            if (this.HasValidLayout)
            {
                actualCount = position.MoveToLineBoundary(count);
            }
            else
            {
                actualCount = 0;
            }

            position.SetLogicalDirection(LogicalDirection.Forward);
            position.Freeze();

            return position;
        }
开发者ID:mind0n,项目名称:hive,代码行数:51,代码来源:TextPointer.cs


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