Chapter 14. Drawing
This chapter covers:
- Drawing with Shapes
- Drawing using direct rendering
- Drawing with Visuals
- Drawing with Geometries
- How to use good pictures to make horrendously ugly backgrounds
It’s interesting that, in most applications—particularly business applications—there isn’t much straight drawing. Yeah, technically, everything is being drawn on the screen, but because of the wealth of built-in controls and third-party controls, you generally don’t do too much shoving stuff on the screen yourself.
In Windows Forms, the most common scenarios for drawing (outside of graphical applications) were to create custom controls or to create a custom look-and-feel for an existing control. We (the authors) have done a lot of this, and it has been a bit of culture shock to know that, most of the time when we want to customize look-and-feel, we don’t have to do low-level drawing code anymore.
But that doesn’t mean that you never have to worry about drawing things. For one thing, if you want to customize the look-and-feel of a control, you’re generally defining a template that uses drawing elements (rectangles, ellipses, lines, and so on) to get what you want. Also, invariably, a few places in even the most staid and boring business application might require some drawing code. For example—in fact, the one we’re going to use throughout this chapter—you might want to provide a graph of some data (figure 14.1).