Brushes Class
.NET Framework 2.0
Brushes for all the standard colors. This class cannot be inherited.
Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)
Assembly: System.Drawing (in system.drawing.dll)
The Brushes class contains static read-only properties that return a Brush object of the color indicated by the property name. You typically do not have to explicitly dispose of the brush returned by a property in this class, unless it is used to construct a new brush.
The following code example demonstrates the how to use a member of the Brushes class to fill a Rectangle. This example should be used with a Windows Form. Paste this code into a form and call this method when handling the form's Paint event, passing e as PaintEventArgs.
private void InstanceRectangleIntersection(PaintEventArgs e) { Rectangle rectangle1 = new Rectangle(50, 50, 200, 100); Rectangle rectangle2 = new Rectangle(70, 20, 100, 200); e.Graphics.DrawRectangle(Pens.Black, rectangle1); e.Graphics.DrawRectangle(Pens.Red, rectangle2); if (rectangle1.IntersectsWith(rectangle2)) { rectangle1.Intersect(rectangle2); if (!rectangle1.IsEmpty) { e.Graphics.FillRectangle(Brushes.Green, rectangle1); } } }
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.