Share via


SolidBrush Sınıf

Tanım

Tek renkli bir fırça tanımlar. Fırçalar dikdörtgenler, üç nokta, pastalar, çokgenler ve yollar gibi grafik şekillerini doldurmak için kullanılır. Bu sınıf devralınamaz.

public ref class SolidBrush sealed : System::Drawing::Brush
public sealed class SolidBrush : System.Drawing.Brush
type SolidBrush = class
    inherit Brush
Public NotInheritable Class SolidBrush
Inherits Brush
Devralma

Örnekler

Aşağıdaki kod örneği kullanarak SolidBrushöğesine bir ListBox gölge ekler.

Bu örnek, Bir Windows Formu ile kullanılacak şekilde tasarlanmıştır. Bu örneği çalıştırmak için bu kodu bir forma yapıştırın ve formun AddShadow olayını işlerken yöntemini çağırın Paint . Formun adlandırılmış listBox1bir ListBox içerdiğinden emin olun.

private:
   void AddShadow( PaintEventArgs^ e )
   {
      // Create two SizeF objects.
      SizeF shadowSize = listBox1->Size;
      SizeF addSize = SizeF(10.5F,20.8F);

      // Add them together and save the result in shadowSize.
      shadowSize = shadowSize + addSize;

      // Get the location of the ListBox and convert it to a PointF.
      PointF shadowLocation = listBox1->Location;

      // Add two points to get a new location.
      shadowLocation = shadowLocation + System::Drawing::Size( 5, 5 );

      // Create a rectangleF. 
      RectangleF rectFToFill = RectangleF(shadowLocation,shadowSize);

      // Create a custom brush using a semi-transparent color, and 
      // then fill in the rectangle.
      Color customColor = Color::FromArgb( 50, Color::Gray );
      SolidBrush^ shadowBrush = gcnew SolidBrush( customColor );
      array<RectangleF>^ temp0 = {rectFToFill};
      e->Graphics->FillRectangles( shadowBrush, temp0 );

      // Dispose of the brush.
      delete shadowBrush;
   }
private void AddShadow(PaintEventArgs e)
{

    // Create two SizeF objects.
    SizeF shadowSize = listBox1.Size;
    SizeF addSize = new SizeF(10.5F, 20.8F);

    // Add them together and save the result in shadowSize.
    shadowSize = shadowSize + addSize;

    // Get the location of the ListBox and convert it to a PointF.
    PointF shadowLocation = listBox1.Location;

    // Add two points to get a new location.
    shadowLocation = shadowLocation + new Size(5, 5);

    // Create a rectangleF. 
    RectangleF rectFToFill = 
        new RectangleF(shadowLocation, shadowSize);

    // Create a custom brush using a semi-transparent color, and 
    // then fill in the rectangle.
    Color customColor = Color.FromArgb(50, Color.Gray);
    SolidBrush shadowBrush = new SolidBrush(customColor);
    e.Graphics.FillRectangles(shadowBrush, new RectangleF[]{rectFToFill});

    // Dispose of the brush.
    shadowBrush.Dispose();
}
Private Sub AddShadow(ByVal e As PaintEventArgs)

    ' Create two SizeF objects.
    Dim shadowSize As SizeF = Size.op_Implicit(listBox1.Size)
    Dim addSize As New SizeF(10.5F, 20.8F)

    ' Add them together and save the result in shadowSize.
    shadowSize = SizeF.op_Addition(shadowSize, addSize)

    ' Get the location of the ListBox and convert it to a PointF.
    Dim shadowLocation As PointF = Point.op_Implicit(listBox1.Location)

    ' Add a Size to the Point to get a new location.
    shadowLocation = PointF.op_Addition(shadowLocation, New Size(5, 5))

    ' Create a rectangleF. 
    Dim rectFToFill As New RectangleF(shadowLocation, shadowSize)

    ' Create a custom brush using a semi-transparent color, and 
    ' then fill in the rectangle.
    Dim customColor As Color = Color.FromArgb(50, Color.Gray)
    Dim shadowBrush As SolidBrush = New SolidBrush(customColor)
    e.Graphics.FillRectangles(shadowBrush, _
        New RectangleF() {rectFToFill})

    ' Dispose of the brush.
    shadowBrush.Dispose()
End Sub

Açıklamalar

Bu sınıf sınıfından devralır Brush .

Not

.NET 6 ve sonraki sürümlerde, bu türü içeren System.Drawing.Common paketi yalnızca Windows işletim sistemlerinde desteklenir. Platformlar arası uygulamalarda bu türün kullanılması derleme zamanı uyarılarına ve çalışma zamanı özel durumlarına neden olur. Daha fazla bilgi için bkz . System.Drawing.Common yalnızca Windows'ta desteklenir.

Oluşturucular

SolidBrush(Color)

Belirtilen rengin yeni SolidBrush bir nesnesini başlatır.

Özellikler

Color

Bu SolidBrush nesnenin rengini alır veya ayarlar.

Yöntemler

Clone()

Bu SolidBrush nesnenin tam bir kopyasını oluşturur.

CreateObjRef(Type)

Uzak bir nesneyle iletişim kurmak için kullanılan bir ara sunucu oluşturmak için gereken tüm ilgili bilgileri içeren bir nesne oluşturur.

(Devralındığı yer: MarshalByRefObject)
Dispose()

Bu Brush nesne tarafından kullanılan tüm kaynakları serbest bırakır.

(Devralındığı yer: Brush)
Dispose(Boolean)

Brush tarafından kullanılan yönetilmeyen kaynakları serbest bırakır ve yönetilen kaynakları isteğe bağlı olarak serbest bırakır.

(Devralındığı yer: Brush)
Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetLifetimeService()
Geçersiz.

Bu örnek için yaşam süresi ilkesini denetleen geçerli yaşam süresi hizmet nesnesini alır.

(Devralındığı yer: MarshalByRefObject)
GetType()

Type Geçerli örneğini alır.

(Devralındığı yer: Object)
InitializeLifetimeService()
Geçersiz.

Bu örneğin yaşam süresi ilkesini denetlemek için bir yaşam süresi hizmet nesnesi alır.

(Devralındığı yer: MarshalByRefObject)
MemberwiseClone()

Geçerli Objectöğesinin sığ bir kopyasını oluşturur.

(Devralındığı yer: Object)
MemberwiseClone(Boolean)

Geçerli MarshalByRefObject nesnenin sığ bir kopyasını oluşturur.

(Devralındığı yer: MarshalByRefObject)
SetNativeBrush(IntPtr)

Türetilmiş bir sınıfta GDI+ fırça nesnesine başvuru ayarlar.

(Devralındığı yer: Brush)
ToString()

Geçerli nesneyi temsil eden dizeyi döndürür.

(Devralındığı yer: Object)

Şunlara uygulanır