Skip to Content
.NET Windows Forms in a Nutshell
book

.NET Windows Forms in a Nutshell

by Ian Griffiths, Matthew Adams
March 2003
Intermediate to advanced
896 pages
32h 35m
English
O'Reilly Media, Inc.
Content preview from .NET Windows Forms in a Nutshell

Name

SolidBrush

Synopsis

This class is the day-to-day workhorse of the GDI+ world. If you cannot find the brush you need in SystemBrushes or Brushes, and you don’t need the fancy effects of the options found in System.Drawing.Drawing2D, you will be using instances of this class (derived from Brush) to fill solid areas of color in your shapes, including the font stroke color when painting text. You can construct an instance from a Color value, and can also set and retrieve the Color through a property of that name over the lifetime of the object.

As with most GDI+ resources, this implements IDisposable and must therefore have its lifetime managed carefully, calling Dispose() when you are finished with it. As with other examples, the C# using idiom is useful here.


public sealed class SolidBrush : Brush : System.Drawing.Internal.ISystemColorTracker {

// Public Constructors

   public SolidBrush(Color color);

// Public Instance Properties

   public Color Color{set; get; }

// Public Instance Methods

   public override object Clone();  // overrides Brush

                  // Protected Instance Methods

   protected override void Dispose(bool disposing);  // overrides Brush

}

Hierarchy

System.Object System.MarshalByRefObject Brush(System.ICloneabl, System.IDisposable) SolidBrush(System.Drawing.Internal.ISystemColorTracker)

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Windows Forms 2.0 Programming

Windows Forms 2.0 Programming

Chris Sells, Michael Weinhardt
Pro C# 7: With .NET and .NET Core

Pro C# 7: With .NET and .NET Core

Andrew Troelsen, Philip Japikse

Publisher Resources

ISBN: 0596003382Supplemental ContentCatalog PageErrata