Пример #1
0
 private Size MeassureTextInternal(string text)
 {
     WindowsAPIUtility.RECT lpRect = new WindowsAPIUtility.RECT
     {
         left   = 0,
         right  = 0,
         top    = 0,
         bottom = 0
     };
     WindowsAPIUtility.DrawText(this.graphicsHandle, text, text.Length, ref lpRect, 0x420);
     return(new Size(lpRect.right, lpRect.bottom));
 }
Пример #2
0
        public void DrawText(string text, Point point, Font font, Color foreColor)
        {
            WindowsAPIUtility.RECT rect = new WindowsAPIUtility.RECT();
            IntPtr hgdiobj = font.ToHfont();
            IntPtr ptr2    = WindowsAPIUtility.SelectObject(this.graphicsHandle, hgdiobj);
            int    iBkMode = WindowsAPIUtility.SetBkMode(this.graphicsHandle, 1);
            int    crColor = WindowsAPIUtility.SetTextColor(this.graphicsHandle, Color.FromArgb(0, foreColor.R, foreColor.G, foreColor.B).ToArgb());
            Size   size    = this.MeassureTextInternal(text);

            rect = new WindowsAPIUtility.RECT
            {
                left   = point.X,
                top    = point.Y,
                right  = rect.left + size.Width,
                bottom = rect.top + size.Height
            };
            WindowsAPIUtility.DrawText(this.graphicsHandle, text, text.Length, ref rect, 0x20);
            WindowsAPIUtility.SetTextColor(this.graphicsHandle, crColor);
            WindowsAPIUtility.SetBkMode(this.graphicsHandle, iBkMode);
            WindowsAPIUtility.SelectObject(this.graphicsHandle, ptr2);
            WindowsAPIUtility.DeleteObject(hgdiobj);
        }