In this chapter we have seen that the Graphics object plays a major role in drawing and represents a canvas to draw graphics curves, shapes, and images.
We started this chapter by discussing the Graphics class properties. Then we discussed various Graphics class methods, which are divided into three categories: draw, fill, and miscellaneous. We saw how to use the draw methods to draw lines, rectangles, ellipses, curves, images, paths, and other graphics objects. We also discussed differences between the draw and fill methods and how to use the fill methods to fill rectangles, ellipses, curves, and graphics paths. We then discussed miscellaneous methods, covering the Clear, MeasureString, FromImage, FromHdc, and FromHwnd methods.
This chapter also presented a couple of real-world applications, showing how to write an application to draw line and pie charts. We also used various methods and properties of the Graphics class to write a PaintBrush-like application, GDI+Painter. Using this application, you can draw lines, rectangles, and ellipses and save the resulting image as a bitmap file.
Having completed this chapter, you should have a good understanding of the Graphics class, its methods and properties, and how to use those methods and properties to write real-world applications.
Pens and brushes are two of the most frequently used objects in the graphics world. In this chapter we discussed pens and brushes briefly. Chapter 4 is dedicated to pens and brushes. You will learn how to create different kinds of pens and brushes to write interactive graphics applications. At the end of Chapter 4 we will add different pen and brush options to GDI+Painter, making it more interactive.
GDI+: The Next-Generation Graphics Interface
Your First GDI+ Application
The Graphics Class
Working with Brushes and Pens
Colors, Fonts, and Text
Rectangles and Regions
Working with Images
Advanced Imaging
Advanced 2D Graphics
Transformation
Printing
Developing GDI+ Web Applications
GDI+ Best Practices and Performance Techniques
GDI Interoperability
Miscellaneous GDI+ Examples
Appendix A. Exception Handling in .NET