Graphics.ResetClip 方法

定義

將這個 Graphics 的裁剪區域重設為無限區域。

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

範例

下列程式碼範例是設計來搭配Windows Forms使用,而且需要 PaintEventArgse ,這是事件處理常式的參數 Paint 。 此程式碼會執行下列動作:

  • 建立左上角 (0、0) 的矩形,並將裁剪區域設定為此矩形。

  • 建立位於 (100、 100) 的第二個矩形,並將裁剪區域設定為此矩形的交集,並將目前的裁剪區域 (第一個矩形) 。

  • 使用實心藍色筆刷填滿包含先前兩個矩形的大型矩形。

  • 將裁剪區域重設為無限。

  • 在兩個裁剪區域周圍繪製矩形;它會針對第一個裁剪矩形使用黑色畫筆,而第二個裁剪區域的紅色畫筆則使用。

結果是只有兩個矩形的交集會填滿藍色。

public:
   void IntersectClipRectangleF2( PaintEventArgs^ e )
   {
      // Set clipping region.
      Rectangle clipRect = Rectangle(0,0,200,200);
      e->Graphics->SetClip( clipRect );

      // Update clipping region to intersection of
      // existing region with specified rectangle.
      RectangleF intersectRectF = RectangleF(100.0F,100.0F,200.0F,200.0F);
      e->Graphics->IntersectClip( intersectRectF );

      // Fill rectangle to demonstrate effective clipping region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Blue ), 0, 0, 500, 500 );

      // Reset clipping region to infinite.
      e->Graphics->ResetClip();

      // Draw clipRect and intersectRect to screen.
      e->Graphics->DrawRectangle( gcnew Pen( Color::Black ), clipRect );
      e->Graphics->DrawRectangle( gcnew Pen( Color::Red ), Rectangle::Round( intersectRectF ) );
   }
private void IntersectClipRectangleF2(PaintEventArgs e)
{

    // Set clipping region.
    Rectangle clipRect = new Rectangle(0, 0, 200, 200);
    e.Graphics.SetClip(clipRect);

    // Update clipping region to intersection of

    // existing region with specified rectangle.
    RectangleF intersectRectF = new RectangleF(100.0F, 100.0F, 200.0F, 200.0F);
    e.Graphics.IntersectClip(intersectRectF);

    // Fill rectangle to demonstrate effective clipping region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Blue), 0, 0, 500, 500);

    // Reset clipping region to infinite.
    e.Graphics.ResetClip();

    // Draw clipRect and intersectRect to screen.
    e.Graphics.DrawRectangle(new Pen(Color.Black), clipRect);
    e.Graphics.DrawRectangle(new Pen(Color.Red), Rectangle.Round(intersectRectF));
}
Private Sub IntersectClipRectangleF2(ByVal e As PaintEventArgs)

    ' Set clipping region.
    Dim clipRect As New Rectangle(0, 0, 200, 200)
    e.Graphics.SetClip(clipRect)

    ' Update clipping region to intersection of

    ' existing region with specified rectangle.
    Dim intersectRectF As New RectangleF(100.0F, 100.0F, 200.0F, 200.0F)
    e.Graphics.IntersectClip(intersectRectF)

    ' Fill rectangle to demonstrate effective clipping region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Blue), 0, 0, _
    500, 500)

    ' Reset clipping region to infinite.
    e.Graphics.ResetClip()

    ' Draw clipRect and intersectRect to screen.
    e.Graphics.DrawRectangle(New Pen(Color.Black), clipRect)
    e.Graphics.DrawRectangle(New Pen(Color.Red), _
    Rectangle.Round(intersectRectF))
End Sub

備註

當 的 Graphics 裁剪區域無限時,不會裁剪此 Graphics 繪製的專案。

適用於