Muokkaa

Jaa


Brushes Class

Definition

Brushes for all the standard colors. This class cannot be inherited.

public ref class Brushes abstract sealed
public ref class Brushes sealed
public static class Brushes
public sealed class Brushes
type Brushes = class
Public Class Brushes
Public NotInheritable Class Brushes
Inheritance
Brushes

Examples

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 = Rectangle(50,50,200,100);
      Rectangle rectangle2 = 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 );
         }
      }
   }
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);
        }
    }
}
  Private Sub InstanceRectangleIntersection( _
      ByVal e As PaintEventArgs)

      Dim rectangle1 As New Rectangle(50, 50, 200, 100)
      Dim rectangle2 As New Rectangle(70, 20, 100, 200)

      e.Graphics.DrawRectangle(Pens.Black, rectangle1)
      e.Graphics.DrawRectangle(Pens.Red, rectangle2)

      If (rectangle1.IntersectsWith(rectangle2)) Then
          rectangle1.Intersect(rectangle2)
          If Not (rectangle1.IsEmpty) Then
              e.Graphics.FillRectangle(Brushes.Green, rectangle1)
          End If
      End If
  End Sub

Remarks

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. For more information about the colors represented by the brushes in this class, see List of colors by name.

Note

In .NET 6 and later versions, the System.Drawing.Common package, which includes this type, is only supported on Windows operating systems. Use of this type in cross-platform apps causes compile-time warnings and run-time exceptions. For more information, see System.Drawing.Common only supported on Windows.

Properties

AliceBlue

Gets a system-defined Brush object.

AntiqueWhite

Gets a system-defined Brush object.

Aqua

Gets a system-defined Brush object.

Aquamarine

Gets a system-defined Brush object.

Azure

Gets a system-defined Brush object.

Beige

Gets a system-defined Brush object.

Bisque

Gets a system-defined Brush object.

Black

Gets a system-defined Brush object.

BlanchedAlmond

Gets a system-defined Brush object.

Blue

Gets a system-defined Brush object.

BlueViolet

Gets a system-defined Brush object.

Brown

Gets a system-defined Brush object.

BurlyWood

Gets a system-defined Brush object.

CadetBlue

Gets a system-defined Brush object.

Chartreuse

Gets a system-defined Brush object.

Chocolate

Gets a system-defined Brush object.

Coral

Gets a system-defined Brush object.

CornflowerBlue

Gets a system-defined Brush object.

Cornsilk

Gets a system-defined Brush object.

Crimson

Gets a system-defined Brush object.

Cyan

Gets a system-defined Brush object.

DarkBlue

Gets a system-defined Brush object.

DarkCyan

Gets a system-defined Brush object.

DarkGoldenrod

Gets a system-defined Brush object.

DarkGray

Gets a system-defined Brush object.

DarkGreen

Gets a system-defined Brush object.

DarkKhaki

Gets a system-defined Brush object.

DarkMagenta

Gets a system-defined Brush object.

DarkOliveGreen

Gets a system-defined Brush object.

DarkOrange

Gets a system-defined Brush object.

DarkOrchid

Gets a system-defined Brush object.

DarkRed

Gets a system-defined Brush object.

DarkSalmon

Gets a system-defined Brush object.

DarkSeaGreen

Gets a system-defined Brush object.

DarkSlateBlue

Gets a system-defined Brush object.

DarkSlateGray

Gets a system-defined Brush object.

DarkTurquoise

Gets a system-defined Brush object.

DarkViolet

Gets a system-defined Brush object.

DeepPink

Gets a system-defined Brush object.

DeepSkyBlue

Gets a system-defined Brush object.

DimGray

Gets a system-defined Brush object.

DodgerBlue

Gets a system-defined Brush object.

Firebrick

Gets a system-defined Brush object.

FloralWhite

Gets a system-defined Brush object.

ForestGreen

Gets a system-defined Brush object.

Fuchsia

Gets a system-defined Brush object.

Gainsboro

Gets a system-defined Brush object.

GhostWhite

Gets a system-defined Brush object.

Gold

Gets a system-defined Brush object.

Goldenrod

Gets a system-defined Brush object.

Gray

Gets a system-defined Brush object.

Green

Gets a system-defined Brush object.

GreenYellow

Gets a system-defined Brush object.

Honeydew

Gets a system-defined Brush object.

HotPink

Gets a system-defined Brush object.

IndianRed

Gets a system-defined Brush object.

Indigo

Gets a system-defined Brush object.

Ivory

Gets a system-defined Brush object.

Khaki

Gets a system-defined Brush object.

Lavender

Gets a system-defined Brush object.

LavenderBlush

Gets a system-defined Brush object.

LawnGreen

Gets a system-defined Brush object.

LemonChiffon

Gets a system-defined Brush object.

LightBlue

Gets a system-defined Brush object.

LightCoral

Gets a system-defined Brush object.

LightCyan

Gets a system-defined Brush object.

LightGoldenrodYellow

Gets a system-defined Brush object.

LightGray

Gets a system-defined Brush object.

LightGreen

Gets a system-defined Brush object.

LightPink

Gets a system-defined Brush object.

LightSalmon

Gets a system-defined Brush object.

LightSeaGreen

Gets a system-defined Brush object.

LightSkyBlue

Gets a system-defined Brush object.

LightSlateGray

Gets a system-defined Brush object.

LightSteelBlue

Gets a system-defined Brush object.

LightYellow

Gets a system-defined Brush object.

Lime

Gets a system-defined Brush object.

LimeGreen

Gets a system-defined Brush object.

Linen

Gets a system-defined Brush object.

Magenta

Gets a system-defined Brush object.

Maroon

Gets a system-defined Brush object.

MediumAquamarine

Gets a system-defined Brush object.

MediumBlue

Gets a system-defined Brush object.

MediumOrchid

Gets a system-defined Brush object.

MediumPurple

Gets a system-defined Brush object.

MediumSeaGreen

Gets a system-defined Brush object.

MediumSlateBlue

Gets a system-defined Brush object.

MediumSpringGreen

Gets a system-defined Brush object.

MediumTurquoise

Gets a system-defined Brush object.

MediumVioletRed

Gets a system-defined Brush object.

MidnightBlue

Gets a system-defined Brush object.

MintCream

Gets a system-defined Brush object.

MistyRose

Gets a system-defined Brush object.

Moccasin

Gets a system-defined Brush object.

NavajoWhite

Gets a system-defined Brush object.

Navy

Gets a system-defined Brush object.

OldLace

Gets a system-defined Brush object.

Olive

Gets a system-defined Brush object.

OliveDrab

Gets a system-defined Brush object.

Orange

Gets a system-defined Brush object.

OrangeRed

Gets a system-defined Brush object.

Orchid

Gets a system-defined Brush object.

PaleGoldenrod

Gets a system-defined Brush object.

PaleGreen

Gets a system-defined Brush object.

PaleTurquoise

Gets a system-defined Brush object.

PaleVioletRed

Gets a system-defined Brush object.

PapayaWhip

Gets a system-defined Brush object.

PeachPuff

Gets a system-defined Brush object.

Peru

Gets a system-defined Brush object.

Pink

Gets a system-defined Brush object.

Plum

Gets a system-defined Brush object.

PowderBlue

Gets a system-defined Brush object.

Purple

Gets a system-defined Brush object.

Red

Gets a system-defined Brush object.

RosyBrown

Gets a system-defined Brush object.

RoyalBlue

Gets a system-defined Brush object.

SaddleBrown

Gets a system-defined Brush object.

Salmon

Gets a system-defined Brush object.

SandyBrown

Gets a system-defined Brush object.

SeaGreen

Gets a system-defined Brush object.

SeaShell

Gets a system-defined Brush object.

Sienna

Gets a system-defined Brush object.

Silver

Gets a system-defined Brush object.

SkyBlue

Gets a system-defined Brush object.

SlateBlue

Gets a system-defined Brush object.

SlateGray

Gets a system-defined Brush object.

Snow

Gets a system-defined Brush object.

SpringGreen

Gets a system-defined Brush object.

SteelBlue

Gets a system-defined Brush object.

Tan

Gets a system-defined Brush object.

Teal

Gets a system-defined Brush object.

Thistle

Gets a system-defined Brush object.

Tomato

Gets a system-defined Brush object.

Transparent

Gets a system-defined Brush object.

Turquoise

Gets a system-defined Brush object.

Violet

Gets a system-defined Brush object.

Wheat

Gets a system-defined Brush object.

White

Gets a system-defined Brush object.

WhiteSmoke

Gets a system-defined Brush object.

Yellow

Gets a system-defined Brush object.

YellowGreen

Gets a system-defined Brush object.

Applies to