共用方式為


Region.MakeInfinite 方法

定義

將這個 Region 物件初始化為無限內部。

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

範例

下列程式碼範例會示範如何使用 MakeInfinite 方法。 此範例的設計目的是要與 Windows Forms 搭配使用。 Create 表單,並將下列程式代碼貼到窗體中。 FillEmptyRegion在表單的事件Paint處理方法中呼叫 方法,並e傳遞為 PaintEventArgs

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

適用於