Graphics.FillRegion(Brush, Region) Metoda

Definicja

Wypełnia wnętrze obiektu Region.

public:
 void FillRegion(System::Drawing::Brush ^ brush, System::Drawing::Region ^ region);
public void FillRegion (System.Drawing.Brush brush, System.Drawing.Region region);
member this.FillRegion : System.Drawing.Brush * System.Drawing.Region -> unit
Public Sub FillRegion (brush As Brush, region As Region)

Parametry

brush
Brush

Brush określa charakterystykę wypełnienia.

region
Region

Region reprezentuje obszar do wypełnienia.

Wyjątki

brush to null.

-lub-

region to null.

Przykłady

Poniższy przykład kodu jest przeznaczony do użycia z Windows Forms i wymaga PaintEventArgseparametru Paint programu obsługi zdarzeń. Kod wykonuje następującą akcję:

  • Tworzy niebieski pędzel.

  • Tworzy prostokąt.

  • Tworzy prostokątny region.

  • Wypełnia prostokątny region na ekranie.

public:
   void FillRegionRectangle( PaintEventArgs^ e )
   {
      // Create solid brush.
      SolidBrush^ blueBrush = gcnew SolidBrush( Color::Blue );

      // Create rectangle for region.
      Rectangle fillRect = Rectangle(100,100,200,200);

      // Create region for fill.
      System::Drawing::Region^ fillRegion = gcnew System::Drawing::Region( fillRect );

      // Fill region to screen.
      e->Graphics->FillRegion( blueBrush, fillRegion );
   }
private void FillRegionRectangle(PaintEventArgs e)
{

    // Create solid brush.
    SolidBrush blueBrush = new SolidBrush(Color.Blue);

    // Create rectangle for region.
    Rectangle fillRect = new Rectangle(100, 100, 200, 200);

    // Create region for fill.
    Region fillRegion = new Region(fillRect);

    // Fill region to screen.
    e.Graphics.FillRegion(blueBrush, fillRegion);
}
Private Sub FillRegionRectangle(ByVal e As PaintEventArgs)

    ' Create solid brush.
    Dim blueBrush As New SolidBrush(Color.Blue)

    ' Create rectangle for region.
    Dim fillRect As New Rectangle(100, 100, 200, 200)

    ' Create region for fill.
    Dim fillRegion As New [Region](fillRect)

    ' Fill region to screen.
    e.Graphics.FillRegion(blueBrush, fillRegion)
End Sub

Uwagi

Element składa Region się z prostokątów i ścieżek. Jeśli region nie zostanie zamknięty, zostanie dodany dodatkowy segment z ostatniego punktu do pierwszego punktu, aby go zamknąć.

Dotyczy