Drawing with the .NET Namespaces
Windows has a very rich user interface. Users interact with it through a visual display; they click menus, buttons, and toolbars; they read text and respond to dialog boxes. All of these are things that must be drawn to the screen. A button is simply a bitmap imagea set of pixels. As such, it must be drawn, and someone must write the code to draw it.
GDI+
All drawing with .NET-managed code happens through the Graphics Device Interface plus (GDI+) layer. GDI+ is the new API Windows uses to provide the .NET Framework with graphics, imaging, printing, and typography capabilities. Prior to .NET, VB programmers mostly had to rely on Win32 API calls into GDI to execute drawing functions. In .NET, GDI+ is wrapped by the drawing namespace. This provides easy, object-oriented access to drawing functions from all .NET languages.
GDI+ shields your application from having to deal with the details and particulars of device drivers. It allows you to send output to the screen or printer without concern for calling into the driver that manages a given device. For example, your application need not write new code to support an Epson printer versus an HP; think if you had to write new code for every graphics card your application had to support. Instead, GDI+ makes the calls to the specific device driver for us, thus insulating our application from the hardware and allowing us to easily create device-independent software.
Practical Applications
GDI+ provides objects like pens and brushesobjects used by programmers to illustrate ideas and to create tools for their users to do the same. If you are creating applications with illustrating capabilities, you see the obvious need for drawing functions. For instance, if your application allows users to select a color, you'll most likely use the Color structure or the ColorPalette class.
Beyond illustration applications, however, you might be surprised by how often drawing functions are required. For instance, word processing applications use lines and curves to render borders for tables, pages, and around text. A search word game might use the DrawLine function to cross out words as users find them. Spreadsheet applications and the like could use the DrawPie method to create pie charts based on user data. CAD (computer-aided design) applications outline objects and calculate distance between points with lines and curves. Even Web applications might create graphics on the server based on user-submitted data. These images could be stored to the file system and displayed out to the user's browser. You can see that, before long, you will more than likely need to execute drawing functions with the .NET Framework Class Library. So, let's get started learning to draw using the .NET namespaces.
Suggestions for Further Exploration
If you're familiar with using GDI and want a quick primer on what's new, check out "What's New in GDI+" inside of the MSDN library, "Programming with the .NET Framework."
For more information on the Win32 GDI functions, see MSDN: Library/Graphics and Multimedia/Windows GDI.
For specific Win32 API calls for the Visual Basic programmer, see Dan Appleman's Visual Basic Programmer's Guide to the Win32 API.