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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.