public TextBoxContext MapPoint(Graphics g, PointF pt, out bool atEndOfLine) { TextBoxContext textBoxContext = null; atEndOfLine = false; TextRun textRun = default(TextRun); int iX = default(int); textBoxContext = this.GetParagraphAndRunIndex(g, (int)pt.X, (int)pt.Y, out textRun, out iX, out atEndOfLine); if (textRun != null) { GlyphData glyphData = textRun.GlyphData; GlyphShapeData glyphScriptShapeData = glyphData.GlyphScriptShapeData; if (glyphData != null && textRun.CharacterCount > 0) { int num = 0; int num2 = 0; int num3 = Win32.ScriptXtoCP(iX, textRun.CharacterCount, glyphScriptShapeData.GlyphCount, glyphScriptShapeData.Clusters, glyphScriptShapeData.VisAttrs, glyphData.Advances, ref textRun.SCRIPT_ANALYSIS, ref num, ref num2); if (Win32.Failed(num3)) { Marshal.ThrowExceptionForHR(num3); } if (textRun.ScriptAnalysis.fLayoutRTL == 1) { if (num == -1) { textBoxContext.TextRunCharacterIndex += textRun.CharacterCount; } else if (pt.X <= 0.0) { TextBoxContext textBoxContext2 = textBoxContext; textBoxContext2.TextRunCharacterIndex = textBoxContext2.TextRunCharacterIndex; } else { textBoxContext.TextRunCharacterIndex += num + num2; } } else { textBoxContext.TextRunCharacterIndex += num + num2; } } } if (textBoxContext == null) { textBoxContext = new TextBoxContext(); } return(textBoxContext); }