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


C# TextPointer.GetLineStartPosition方法代码示例

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


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

示例1: GetLineForTextPointer

        public static int GetLineForTextPointer(this RichTextBox rtb, TextPointer tp)
        {
            TextPointer tpLine = tp.GetLineStartPosition(0);
            int lineNr = 1;

            for (TextPointer linePointer = rtb.Document.ContentStart.GetLineStartPosition(0);
                linePointer.CompareTo(tpLine) < 0; linePointer = linePointer.GetLineStartPosition(1))
            {
                lineNr++;
            }

            return lineNr;
        }
开发者ID:software-engineering-amsterdam,项目名称:poly-ql,代码行数:13,代码来源:RichTextBoxExtensions.cs

示例2: FindNext

      /// <summary>
      /// Find the input string within the document, starting at the specified position.
      /// </summary>
      /// <param name="position">the current text position</param>
      /// <param name="input">input text</param>
      /// <returns>An <see cref="TextRange"/> representing the (next) matching string within the text container. Null if there are no matches.</returns>
      public TextRange FindNext(ref TextPointer position, String input)
      {
         FindText(input);

         foreach (var result in _searchHits)
         {
            if (position.CompareTo(result.End) < 0)
            {
               position = result.Start;
               double top = this.PointToScreen(position.GetLineStartPosition(0).GetCharacterRect(LogicalDirection.Forward).TopLeft).Y + this.PointFromScreen(new System.Windows.Point(0, 0)).Y;
               Trace.WriteLine(string.Format(" Top: {0}, CharOffset: {1}", top, position));
               ScrollViewer.ScrollToVerticalOffset(ScrollViewer.VerticalOffset + top);
               position = result.End;
               return result;
            }
         }
         return null;
      }
开发者ID:ForNeVeR,项目名称:PoshConsole,代码行数:24,代码来源:ConsoleControl.cs

示例3: GetColumnNumberFromSelection

        internal static int GetColumnNumberFromSelection(TextPointer position)
        {
            if (position == null)
            {
                return 0;
            }

            int linesMoved;
            TextPointer lineStartPosition = position.GetLineStartPosition(0, out linesMoved);

            int columnNumber = 0;
            do
            {
                columnNumber++;
                position = position.GetNextInsertionPosition(LogicalDirection.Backward);
            }
            while (position != null && position.CompareTo(lineStartPosition) > 0);

            return columnNumber;
        }
开发者ID:DVitinnik,项目名称:UniversityApps,代码行数:20,代码来源:Helper.cs

示例4: GetLineNumberFromSelection

        internal static int GetLineNumberFromSelection(TextPointer position)
        {
            if (position == null)
            {
                return 0;
            }
            
            int lineNumber = 0;
            int linesMoved;
            do
            {
                position = position.GetLineStartPosition(-1, out linesMoved);
                lineNumber++;
            }
            while (position != null && linesMoved != 0);

            return lineNumber;
        }
开发者ID:DVitinnik,项目名称:UniversityApps,代码行数:18,代码来源:Helper.cs

示例5: GetLineNumber

 private int GetLineNumber(TextPointer pointer)
 {
     int someBigNumber = int.MaxValue;
     int lineMoved;
     pointer.GetLineStartPosition(-someBigNumber, out lineMoved);
     return -lineMoved;
 }
开发者ID:caindy,项目名称:psash,代码行数:7,代码来源:MainWindow.xaml.cs

示例6: GetInputLine

 private TextRange GetInputLine(TextPointer pointer)
 {
     var nextStart = pointer.GetLineStartPosition(1);
     var lineEnd = (nextStart ?? pointer.DocumentEnd).GetInsertionPosition(LogicalDirection.Backward);
     var lineStart = pointer.GetLineStartPosition(0);
     var prevEnd = lineStart.GetInsertionPosition(LogicalDirection.Backward);
     if (GetLineNumber(prevEnd) != 0) //are we already at the beginning of the content?
         lineStart = SearchBackwardsForLineContinuation(lineStart, prevEnd);
     return new TextRange(lineStart, lineEnd);
 }
开发者ID:caindy,项目名称:psash,代码行数:10,代码来源:MainWindow.xaml.cs


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