Region.MakeInfinite 方法

定义

将此 Region 对象初始化为无限内部。

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

示例

下面的代码示例演示如何使用 MakeInfinite 方法。 此示例旨在与 Windows 窗体 一起使用。 Create窗体并将以下代码粘贴到其中。 FillEmptyRegion在窗体的事件Paint处理方法中调用 方法,作为 ePaintEventArgs传递。

private:
   void FillInfiniteRegion( 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 MakeInfinite.
      smallRegion->MakeInfinite();

      // Fill the region in red and draw the original rectangle
      // in black. Note that the entire form is filled in.
      e->Graphics->FillRegion( Brushes::Red, smallRegion );
      e->Graphics->DrawRectangle( Pens::Black, originalRectangle );
   }
private void FillInfiniteRegion(PaintEventArgs e)
{
    // Create a region from a rectangle.
    Rectangle originalRectangle = new Rectangle(40, 40, 40, 50);
    Region smallRegion = new Region(originalRectangle);

    // Call MakeInfinite.
    smallRegion.MakeInfinite();

    // Fill the region in red and draw the original rectangle
    // in black. Note that the entire form is filled in.
    e.Graphics.FillRegion(Brushes.Red, smallRegion);
    e.Graphics.DrawRectangle(Pens.Black, originalRectangle);
}
Private Sub FillInfiniteRegion(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 MakeInfinite.
    smallRegion.MakeInfinite()

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

End Sub

适用于