11.4. System.Drawing namespace

The main class in this namespace is Graphics. It provides the device context for drawing. We can create device contexts from handles by using the FromHDC(IntPtr ) method, Windows handles by using the FromHWnd(IntPtr ) method, and images by using the FromImage(Image ) method. After we get the device context, we can manipulate regions, perform rendering and transformation, work with metafiles, and draw various geometric figures – arcs, Bezier curves, ellipses, lines, and so on – on the device surface. This is supported by the set of DrawXXX methods shown below:

  • DrawArc;

  • DrawBezier;

  • DrawClosedCurve;

  • DrawCurve;

  • DrawEllipse;

  • DrawIcon;

  • DrawImage;

  • DrawImageUnscaled;

  • DrawLine;

  • DrawLines;

  • DrawPath;

  • DrawPie;

  • DrawPolygon;

  • DrawRectangle ...

Get A Programmer's Guide to .NET now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.