03.01.2015 Views

C# 5.0 Programmer's Reference

Visual Studio 2013 C# 5.0 Programmer's Reference

Visual Studio 2013 C# 5.0 Programmer's Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

366 ❘ CHAPTER 16 Printing<br />

(continued)<br />

Method<br />

DrawImageUnscaled<br />

DrawLine<br />

DrawLines<br />

DrawPath<br />

DrawPie<br />

DrawPolygon<br />

DrawRectangle<br />

DrawRectangles<br />

DrawString<br />

Description<br />

Draws an image without scaling. If you know that you will not<br />

resize the image, this is faster than DrawImage.<br />

Draws a line.<br />

Draws a series of connected lines. This is much faster than using<br />

DrawLine repeatedly.<br />

Draws a GraphicsPath object.<br />

Draws a pie slice taken from an ellipse.<br />

Draws a polygon. This is similar to DrawLines except it connects<br />

the last point to the first point.<br />

Draws a rectangle with horizontal and vertical sides. (In other<br />

words, it can’t draw rotated rectangles.)<br />

Draws a series of rectangles. This is much faster than using<br />

DrawRectangle repeatedly.<br />

Draws text.<br />

The methods listed in the preceding table draw the outline of something such as a line, rectangle,<br />

or ellipse. The Graphics class provides corresponding methods that fill many of these shapes. For<br />

example, the DrawRectangle method outlines a rectangle, and the corresponding FillRectangle<br />

method fills a rectangle. The filling methods include FillClosedCurve, FillEllipse, FillPath,<br />

FillPie, FillPolygon, FillRectangle, and FillRectangles.<br />

The Draw methods take a pen as a parameter and use that pen to determine how the outline is drawn.<br />

In contrast, the Fill methods take a brush as a parameter and use the brush to determine how to fill<br />

the area.<br />

The one exception is the DrawString method, which uses a brush to fill text even though its name<br />

begins with Draw.<br />

The sections “Pens” and “Brushes” later in this chapter describe pens and brushes in greater detail.<br />

See the online help for specific information about the Graphics class’s drawing and filling<br />

methods. You can find links to the pages describing these methods at the Graphics class’s web<br />

page msdn.microsoft.com/library/system.drawing.graphics.<br />

Obtaining Graphics Objects<br />

There are several ways a program can obtain a Graphics object on which to draw. You’ve already<br />

seen that the PrintDocument’s PrintPage event handler provides an e.Graphics parameter.<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!