TextBox控件
public Point GetPositionFromCharacterIndex()
{
int index = txtBox.CaretIndex;
if (txtBox.TextWrapping == TextWrapping.Wrap) throw new NotSupportedException();
var text = txtBox.Text.Substring(0, index);
int lastNewLineIndex = text.LastIndexOf('\r');
var leftText = lastNewLineIndex != -1 ? text.Substring(lastNewLineIndex + 1) : text;
Typeface typeface = new Typeface(rich.FontFamily,
txtBox.F