private CaretInfo MapLocation(Win32DCSafeHandle hdc, TextBoxContext location, bool relativeToRun, bool moveCaretToNextLine, out TextRun run) { CaretInfo caretInfo = null; run = null; int lineYOffset = default(int); int lineHeight = default(int); int iCP = default(int); bool isFirstLine = default(bool); bool isLastLine = default(bool); Point paragraphAndRunCoordinates = this.GetParagraphAndRunCoordinates(hdc, location, moveCaretToNextLine, out lineYOffset, out lineHeight, out run, out iCP, out isFirstLine, out isLastLine); if (run != null) { GlyphData glyphData = run.GlyphData; GlyphShapeData glyphScriptShapeData = glyphData.GlyphScriptShapeData; int num = 0; if (glyphData != null && run.CharacterCount > 0) { int num2 = Win32.ScriptCPtoX(iCP, false, run.CharacterCount, glyphScriptShapeData.GlyphCount, glyphScriptShapeData.Clusters, glyphScriptShapeData.VisAttrs, glyphData.Advances, ref run.SCRIPT_ANALYSIS, ref num); if (Win32.Failed(num2)) { Marshal.ThrowExceptionForHR(num2); } } caretInfo = new CaretInfo(); CachedFont cachedFont = run.GetCachedFont(hdc, this.FontCache); caretInfo.Height = cachedFont.GetHeight(hdc, this.FontCache); caretInfo.Ascent = cachedFont.GetAscent(hdc, this.FontCache); caretInfo.Descent = cachedFont.GetDescent(hdc, this.FontCache); caretInfo.LineHeight = lineHeight; caretInfo.LineYOffset = lineYOffset; caretInfo.IsFirstLine = isFirstLine; caretInfo.IsLastLine = isLastLine; List <Paragraph> rTParagraph = this.RTParagraphs; int y = paragraphAndRunCoordinates.Y - caretInfo.Ascent; if (relativeToRun) { caretInfo.Position = new Point(num, y); } else { caretInfo.Position = new Point(paragraphAndRunCoordinates.X + num, y); } } return(caretInfo); }
public int GetHeight(Win32DCSafeHandle hdc, FontCache fontCache) { CachedFont cachedFont = this.GetCachedFont(hdc, fontCache); return(cachedFont.GetHeight(hdc, fontCache)); }