Key Classes Related to Drawing

The process of drawing with the .NET Framework Class Library involves a whole host of classes. These classes can be found inside of the System.Drawing namespace and its associated third-level namespaces. At a glance, the drawing namespace in .NET is made up of the following:

  • System.Drawing: Provides basic graphics functionality. This chapter focuses on this namespace.

  • System.Drawing.Design: Focuses on providing functionality for extending the design time environment. This namespace is beyond the scope of this book.

  • System.Drawing.Drawing2D: Provides two-dimensional and vector graphics classes and methods. This namespace is covered within this chapter.

  • System.Drawing.Imaging: Exposes advanced imaging functionality. This namespace is beyond the scope of this book.

  • System.Drawing.Printing: Gives you classes to manage output to a print device. Chapter 6, “Font, Text, and Printing Operations,” covers this namespace.

  • System.Drawing.Text: Wraps fonts and type management. Chapter 6 covers this namespace.

This chapter is focused on the System.Drawing and System.Drawing.Drawing2D namespaces. These two namespaces contain classes that are fundamental to the execution of common programming tasks with .NET. The namespaces Printing and Text are covered elsewhere in the book, and Design and Imaging are simply beyond the scope of this book as they encapsulate more specialized features. There are certainly great classes within these namespaces, and we encourage you to use this chapter as a leaping-off point to your own exploring. Table 9.1 lists the key classes we will be discussing.

Table 9.1. Key Classes of System.Drawing and System.Drawing.Drawing2D
Class Description
Functional Drawing Classes
Graphics The Graphics class is the premier class within the namespace for executing drawing and filling shapes.
GraphicsState The GraphicsState class is used to save the state of the Graphics object between calls to transformations and the like. This class is used with the BeginContainer and EndContainer methods of the Graphics class.
Drawing Basics
Pen The Pen class is used to draw the outlines of objects (lines, rectangles, ellipses, and so on). It defines the line weight and color similar to an actual pen.
Rectangle The Rectangle structure stores information about a rectangle (location, width, and height). This structure is used to draw rectangles, ellipses, pies, and so on.
CustomLineCap The CustomLineCap class is used to create a custom, user-defined end cap for a line.
Working with Images
Bitmap The Bitmap class encapsulates an image of type bitmap.
Icon The Icon class encapsulates a small bitmap image used to represent an object.
Image The Image class is the abstract base class used for both the Bitmap and the Icon classes.
Graphic Fills
Brush The abstract Brush class is the base class for the various brush classes throughout the drawing namespace. Brushes are used to fill shapes with colors, textures, and patterns.
SolidBrush The SolidBrush class is a brush made of one solid color.
TextureBrush The TextureBrush class is a brush made up of an image. It allows you to fill shapes with various versions of an image.
HatchBrush The HatchBrush class is used to create a brush based on a predefined pattern, a foreground color, and a background color.
LinearGradientBrush The LinearGradientBrush is used to create brushes that blend two colors across an object.
PathGradientBrush The PathGradientBrush can create a brush object that can be used to fill paths.
Graphic Storage
Region The Region class is used to describe the inside of a graphics shape made of rectangles and paths.
RegionData The RegionData class is used to store the data that makes up a region.
GraphicsPath The GraphicsPath class groups connected lines and curves for manipulation as a whole.
PathData The PathData class is used to store data that makes up a GraphicsPath.
Utility Classes
Point The Point structure allows you to group x and y coordinates as a single object or point on a 2D plane.
Size Similar to the Point structure, the Size structure groups width and height.
Matrix The Matrix class is the mathematical foundation used to transform graphics.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.143.137