Summary
GDI+ provides a very powerful set of drawing tools. Access to drawing
surfaces, whether they are windows, bitmaps, or metafiles, is
provided through the Graphics
class. This supplies
methods for drawing primitive shapes whose visual attributes are
specified with Brush
and Pen
objects. We can augment the set of primitives by building our own
composite shapes using the GraphicsPath
class.
There is special support for text, both for specifying the appearance
with the Font
class, and for controlling
formatting with the StringFormat
class. There is
also support for creating and displaying predrawn images using either
the Bitmap
or Metafile
classes.
Such images can be loaded from disk or created on the fly. Finally,
we saw how the Graphics
object can automatically
apply a transformation to every drawing operation, making it easy to
implement features such as scrolling and zooming, and allowing us to
draw sheared and rotated elements even with primitives that provide
no direct support for this.
All these facilities enable us to exert a very fine level of control over our components’ behavior. In the next two chapters we will see how to further enhance our controls by building in awareness of the development environment, and adding so-called design-time features.
Get .NET Windows Forms in a Nutshell 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.