O'Reilly logo

.NET Common Language Runtime Unleashed by Kevin Burton

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

System.Drawing

This namespace provides classes and support for construction and display of arbitrary graphical objects.

A few examples of using classes in this namespace can be found in the ImageProcessing application in Appendix A,“C# Basics.”

You can also find a simple example in the Scribble directory. You create two cached variables:

private Graphics graphics = null;
private Point lastPoint;

When you click on a mouse button, the OnMouseDown event handler is called, the Graphics object is created, and the current point is saved.

graphics = CreateGraphics();
lastPoint = new Point(e.X, e.Y);

When the mouse button is released, the Graphics object is destroyed.

graphics.Dispose();
graphics = null;

The OnMouseMove handler is called and a ...

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