本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例5: GetLineNumber
private int GetLineNumber(TextPointer pointer)
{
int someBigNumber = int.MaxValue;
int lineMoved;
pointer.GetLineStartPosition(-someBigNumber, out lineMoved);
return -lineMoved;
}
示例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);
}