本文整理匯總了C#中System.Windows.Media.TextFormatting.TextLine.GetCharacterHitFromDistance方法的典型用法代碼示例。如果您正苦於以下問題:C# TextLine.GetCharacterHitFromDistance方法的具體用法?C# TextLine.GetCharacterHitFromDistance怎麽用?C# TextLine.GetCharacterHitFromDistance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Media.TextFormatting.TextLine
的用法示例。
在下文中一共展示了TextLine.GetCharacterHitFromDistance方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetVisualColumn
/// <summary>
/// Gets the visual column from a document position (relative to top left of the document).
/// If the user clicks between two visual columns, rounds to the nearest column.
/// </summary>
public int GetVisualColumn(TextLine textLine, double xPos, bool allowVirtualSpace)
{
if (xPos > textLine.WidthIncludingTrailingWhitespace) {
if (allowVirtualSpace && textLine == TextLines[TextLines.Count - 1]) {
int virtualX = (int)Math.Round((xPos - textLine.WidthIncludingTrailingWhitespace) / textView.WideSpaceWidth);
return VisualLengthWithEndOfLineMarker + virtualX;
}
}
CharacterHit ch = textLine.GetCharacterHitFromDistance(xPos);
return ch.FirstCharacterIndex + ch.TrailingLength;
}