DekGenius.com
[ Team LiB ] Previous Section Next Section

1.6 The .NET Framework Class Library

All platform services are exposed through the .NET Framework Class Library. So whether you want to make a window appear, read a file, open a network connection, parse an XML document, or use any of the other myriad features of the platform, you will do so by using one or more classes in the class library.

The class library is divided up into namespaces . For each area of the API, there is an appropriate namespace, e.g., XML services are provided by the System.Xml namespace, GUI services are provided by the System.Windows.Forms namespace, and graphical services are provided by the System.Drawing namespace. Namespaces are hierarchical, and large namespaces are frequently subdivided into several smaller namespaces, e.g., the design-time parts of the Windows Forms API appear in the System.Windows.Forms.Design namespace.

Because the Class Library replaces large amounts of the Win32 API, and also adds new functionality not previously available, it is large and contains many namespaces. This book concentrates on the Windows Forms namespace, and the related System.Drawing namespace, although we will discuss other relevant classes as necessary.

1.6.1 Windows Forms and GDI+

Windows Forms is the name given to the parts of the .NET Framework Class Libraries used for building rich client applications, i.e., traditional GUI applications such as those built using the MFC before .NET. Central to Windows Forms is the Control class, the foundation of all UI applications and the subject of the next chapter. In fact, almost everything that happens in a .NET UI application revolves around controls, so most of the rest of the book is about controls.

GDI and GDI+

There are actually two versions of GDI+, one for unmanaged (non-.NET) code and one for managed code. The unmanaged GDI+ came first—it shipped with Windows XP, and a redistributable for other versions of Windows was released at the same time. Managed GDI+ shipped a few months later with the release of .NET, and is described in the documentation as "a set of wrappers." This turns out to be a somewhat misleading description, because it is not in fact a wrapper for unmanaged GDI+. The two APIs are nearly identical, both are object oriented and provide a set of objects for two-dimensional drawing and image manipulation. The object models look exactly the same, except one is a classic C++ object model, while the other is a .NET object model. However, neither is a wrapper for the other—both turn out to be wrappers for the same undocumented API. They may look the same, but they are in fact two parallel implementations of the same thing, one in managed code, the other in unmanaged code.


GDI+ is the successor to Win32's GDI—it is the API used for drawing. If a Windows Forms application wants to customize its own appearance, it must use GDI+, so this API (which lives in the System.Drawing namespace) is a fundamental part of most .NET GUI development. It provides a wide range of drawing facilities, including support for text, bitmaps, metafiles, line drawing, Bezier curves, and filled paths. It also provides advanced high-quality rendering features, such as antialiasing support for all graphical output (as opposed to just on text), and interpolation for bitmap resizing (both bilinear and bicubic).

The rest of this book is devoted to describing how to use the classes in these Windows Forms and GDI+ namespaces.

    [ Team LiB ] Previous Section Next Section