private void DrawSimpleText(Rectangle rc, int yOffset, string text, Color col, Color bkCol) { Win32Util.SetTextColor(hdc, col); Win32Util.SetBkColor(hdc, bkCol); Win32Util.ExtTextOut(hdc, rc.X, rc.Y + yOffset, rc, text); }
protected override void OnPaint(PaintEventArgs pe) { try { base.OnPaint(pe); Rectangle clientRectangle = base.ClientRectangle; ControlPaint.DrawBorder3D(pe.Graphics, clientRectangle, Border3DStyle.Sunken); if ((this.isCompatibleOS && (XPTheme.IsThemeActive() == 1)) && ((this.m_htheme == IntPtr.Zero) /* && (this.boxStyle == Style.XpStyle)*/)) { this.m_htheme = XPTheme.OpenThemeData(IntPtr.Zero, "Edit"); } IntPtr handle = this.Font.ToHfont(); IntPtr hdc = pe.Graphics.GetHdc(); Win32Util.SetBkMode(hdc, 1); Win32Util.SelectObject(hdc, handle); if (!base.Enabled) { Win32Util.SetTextColor(hdc, Color.FromName("ControlDarkDark")); } else if (this.sDisplay.IndexOf("-") != -1) { Win32Util.SetTextColor(hdc, this.m_NegativeColor); } else { Win32Util.SetTextColor(hdc, this.ForeColor); } if (this.m_htheme != IntPtr.Zero) { RECT rect = new RECT(base.ClientRectangle); IntPtr hd = hdc; XPTheme.DrawThemeBackground(this.m_htheme, hd, 1, base.Enabled ? 1 : 4, ref rect, ref rect); Rectangle clip = base.ClientRectangle; clip.Inflate(-1, -1); Win32Util.FillRect(hdc, clip, this.BackColor); } Size textExtent = Win32Util.GetTextExtent(hdc, this.sDisplay); Win32Util.ExtTextOut(hdc, (clientRectangle.Width - textExtent.Width) - this.nShiftLeft, clientRectangle.Y + 3, clientRectangle, this.sDisplay); if (this.m_nDecimalNumber > 0) { for (int i = 1; i <= (this.m_nDecimalNumber + 2); i++) { if (this.cp[i]) { Point point = new Point(); point.Y = 3; if (i < (this.m_nDecimalNumber + 2)) { string str = this.sDisplay.Substring(this.sDisplay.Length - ((this.m_nDecimalNumber + 2) - i), (this.m_nDecimalNumber + 2) - i); Size size2 = Win32Util.GetTextExtent(hdc, str); point.X = (clientRectangle.Width - size2.Width) - this.nShiftLeft; } else { point.X = clientRectangle.Width - this.nShiftLeft; } this.ptPos = point; if (this.Focused) { SetCaretPos(this.ptPos.X, this.ptPos.Y); } } } } else { Point point2 = new Point(); point2.Y = 3; point2.X = clientRectangle.Width - this.nShiftLeft; this.ptPos = point2; if (this.Focused) { SetCaretPos(this.ptPos.X, this.ptPos.Y); } } pe.Graphics.ReleaseHdc(hdc); if (this.sOldText != this.sDisplay) { this.sOldText = this.sDisplay; this.OnTextChanged(EventArgs.Empty); } } catch (Exception ex) { Debug.Write(ex.Message); } }