Region.MakeEmpty Region.MakeEmpty Region.MakeEmpty Region.MakeEmpty Method

Определение

Инициализирует область Region для пустой внутренней части.Initializes this Region to an empty interior.

public:
 void MakeEmpty();
public void MakeEmpty ();
member this.MakeEmpty : unit -> unit
Public Sub MakeEmpty ()

Примеры

В следующем примере кода показано, как использовать Region конструктор и MakeEmpty метод.The following code example demonstrates how to use the Region constructor and MakeEmpty method. Этот пример предназначен для использования с Windows Forms.This example is designed to be used with Windows Forms. Создайте форму и вставьте в нее следующий код.Create a form and paste the following code into it. Вызовите FillEmptyRegion метод в методе обработки Paint событий формы, передав e его как PaintEventArgs.Call the FillEmptyRegion method in the form's Paint event-handling method, passing e as PaintEventArgs.

private:
   void FillEmptyRegion( PaintEventArgs^ e )
   {
      // Create a region from a rectangle.
      Rectangle originalRectangle = Rectangle(40,40,40,50);
      System::Drawing::Region^ smallRegion = gcnew System::Drawing::Region( originalRectangle );

      // Call MakeEmpty.
      smallRegion->MakeEmpty();

      // Fill the region in red and draw the original rectangle
      // in black. Note there is nothing filled in.
      e->Graphics->FillRegion( Brushes::Red, smallRegion );
      e->Graphics->DrawRectangle( Pens::Black, originalRectangle );
   }
private void FillEmptyRegion(PaintEventArgs e)
{

    // Create a region from a rectangle.
    Rectangle originalRectangle = new Rectangle(40, 40, 40, 50);
    Region smallRegion = new Region(originalRectangle);

    // Call MakeEmpty.
    smallRegion.MakeEmpty();

    // Fill the region in red and draw the original rectangle
    // in black. Note there is nothing filled in.
    e.Graphics.FillRegion(Brushes.Red, smallRegion);
    e.Graphics.DrawRectangle(Pens.Black, originalRectangle);

}
Private Sub FillEmptyRegion(ByVal e As PaintEventArgs)

    ' Create a region from a rectangle.
    Dim originalRectangle As New Rectangle(40, 40, 40, 50)
    Dim smallRegion As New Region(originalRectangle)

    ' Call MakeEmpty.
    smallRegion.MakeEmpty()

    ' Fill the region in red and draw the original rectangle
    ' in black. Note there is nothing filled in.
    e.Graphics.FillRegion(Brushes.Red, smallRegion)
    e.Graphics.DrawRectangle(Pens.Black, originalRectangle)

End Sub

Применяется к