O'Reilly logo

Professional C# 2005 by Allen Jones, Morgan Skinner, Karli Watson, Jay Glynn, Bill Evjen, Christian Nagel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 25. Graphics with GDI+

This is the third of the three chapters that deal with user interaction and the .NET Framework. Chapter 23, "Windows Forms," focused on Windows Forms and discussed how to display a dialog box or SDI or MDI window, and how to place various controls such as buttons, text boxes, and list boxes. Chapter 24, "Viewing .NET Data," looked at working with data in Windows Forms using a number of the Windows Forms controls that work with the disparate data sources that you might encounter.

Although these standard controls are powerful and, by themselves, quite adequate for the complete user interface for many applications, there are some situations in which you need more flexibility. For example, you might want to draw text in a given font in a precise position in a window, display images without using a picture box control, or draw simple shapes or other graphics. None of this can be done with the controls discussed in Chapter 23. To display that kind of output, the application must instruct the operating system what to display and where in its window to display it.

Therefore, this chapter shows you how to draw a variety of items including:

  • Lines and simple shapes

  • .BMP images and other image files

  • Text

In the process, you'll need to use a variety of helper objects, including pens (to define the characteristics of lines), brushes (to define how areas are filled in), and fonts (to define the shape of the characters of text). The chapter also goes into some detail on ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required