/// <inheritdoc /> public override int GetHashCode() { unchecked { return(((PartText != null ? PartText.GetHashCode() : 0) * 397) ^ (Location != null ? Location.GetHashCode() : 0)); } }
public int GetSymbolByOffset(int x, RichTextParameters parameters, IntPtr hdc) { if (x < 0) { return(-1); } Font hFont = GetParametrizedFont(parameters); RECT rc = new RECT(); rc.left = 0; rc.top = 0; int currentX = 0; IntPtr oldFont = Win32Declarations.SelectObject(hdc, ourFontCache.GetHFont(hFont)); try { for (int i = 0; i < PartText.Length; i++) { Win32Declarations.DrawText(hdc, PartText.Substring(i, 1), 1, ref rc, DrawTextFormatFlags.DT_CALCRECT | DrawTextFormatFlags.DT_SINGLELINE | DrawTextFormatFlags.DT_NOPREFIX | DrawTextFormatFlags.DT_NOCLIP); currentX += rc.right - rc.left; if (currentX > x) { return(i); } } return(-1); } finally { Win32Declarations.SelectObject(hdc, oldFont); } }