As we discussed in Chapter 3, the Graphics class provides methods to clip regions. Using these methods, an application can restrict where graphics objects are drawn. One major use of clipping regions is to repaint only part of a control. In some cases painting an entire form is costly in terms of time and memory resources. Clipping plays a vital role by painting only the desired area. The Graphics class provides the SetClip, ResetClip, IntersectClip, ExcludeClip, and TranslateClip methods to use in clipping operations.
ExcludeClip excludes the area specified by an argument of type Rectangle or a Region and updates the clipping region. Listing 6.11 fills a rectangle, excluding one small rectangle and a region.