DrawString with solid brush and rectangle

image_pdfimage_print
   
 
using System;
using System.Drawing;
using System.Windows.Forms;
   
class HuckleberryFinnHalfHeight: Form
{
     public static void Main()
     {
          Application.Run(new HuckleberryFinnHalfHeight());
     }
     public HuckleberryFinnHalfHeight()
     {
          ResizeRedraw = true;
     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          Graphics  grfx = pea.Graphics;
          int       cx   = ClientSize.Width;
          int       cy   = ClientSize.Height;
          Pen       pen  = new Pen(ForeColor);
          Rectangle rect = new Rectangle(0, 0, cx / 2, cy / 2);
   
          grfx.DrawString("some", Font, new SolidBrush(ForeColor), rect);
   
          grfx.DrawLine(pen, 0,      cy / 2, cx / 2, cy / 2);
          grfx.DrawLine(pen, cx / 2, 0,      cx / 2, cy / 2);
     }
}

    


This entry was posted in 2D Graphics. Bookmark the permalink.