5. Drawing Basics
As handy as forms are and as rich as the set of built-in controls is, sometimes neither is sufficient to render the state of your application.[1] In that case, you need to draw the state yourself. You may be drawing to the ...
Drawing to the Screen
No matter what kind of drawing you're doing, the underlying abstraction is the Graphics class from the System.Drawing namespace. The Graphics class provides the abstract surface on which you're drawing, whether the results ...
Colors
So far, I've been drawing the ellipse in my form using a built-in dark blue brush. A brush, as you'll see, is for filling the interior of a shape, whereas a pen is used to draw the edge of a shape. Either way, suppose I'm not quite happy ...
Brushes
The System.Drawing.Brush class serves as a base class for several kinds of brushes to suit a variety of needs. Figure 5.3 shows the five derived brush classes provided in the System.Drawing and System.Drawing.Drawing2D namespaces.
Fig...
Pens
Whereas the Brush classes are used to fill shapes, the Pen class is used to frame shapes. The interesting members are shown here:
namespace System.Drawing {
sealed class Pen : IDisposable, {
// Constructors
public Pen(Brush bru...
Shapes
Now that you know how to frame and fill shapes with pens and brushes, you might be interested in the shapes themselves. Figure 5.16 shows what's available.
Figure 5.16. The Basic Shapes (See Plate 11)
The edges of all ...
Paths
In addition to using the basic shapes, you can compose and draw shapes together using a path. A path, modeled via the GraphicsPath class, is very much like a Graphics object, in that it's a logical container of zero or more shapes (called fi...
Images
As useful as curves and lines are, most modern applications also include the need to load and display professionally produced, prepackaged images. Also, some applications themselves produce images that can be saved to a file for later displ...
Where Are We?
In this chapter, we've discussed the basics of drawing, including colors, brushes, pens, shapes, paths, and images. Of course, that's not all you need to know about drawing in your Windows Forms applications and controls. Chapter 6: ...
С 2009 года мы стали переводить структура сайта на различные языки. Сайт теперь будет содержать книги не только на английском языке, но также и на других европейских языках, в том числе и на Русском языке.