Graphics.ExcludeClip 方法

定義

更新這個 Graphics 的裁剪區域,以排除由 Rectangle 結構所指定的區域。

多載

ExcludeClip(Region)

更新這個 Graphics 的裁剪區域,以排除由 Region 所指定的區域。

ExcludeClip(Rectangle)

更新這個 Graphics 的裁剪區域,以排除由 Rectangle 結構所指定的區域。

ExcludeClip(Region)

來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs

更新這個 Graphics 的裁剪區域,以排除由 Region 所指定的區域。

public:
 void ExcludeClip(System::Drawing::Region ^ region);
public void ExcludeClip (System.Drawing.Region region);
member this.ExcludeClip : System.Drawing.Region -> unit
Public Sub ExcludeClip (region As Region)

參數

region
Region

Region,指定要從裁剪區域排除的區域。

範例

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

  • 建立 100 像素的 100 像素矩形,其左上角位於座標 (100,100) 。

  • 設定裁剪區域以排除矩形。

  • 以純藍色筆刷填入 300 像素的 300 像素矩形,其左上角位於座標 (0,0) 。

結果是藍色矩形,其右下角缺少正方形區域。

public:
   void ExcludeClipRegion( PaintEventArgs^ e )
   {
      // Create rectangle for region.
      Rectangle excludeRect = Rectangle(100,100,200,200);

      // Create region for exclusion.
      System::Drawing::Region^ excludeRegion = gcnew System::Drawing::Region( excludeRect );

      // Set clipping region to exclude region.
      e->Graphics->ExcludeClip( excludeRegion );

      // Fill large rectangle to show clipping region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Blue ), 0, 0, 300, 300 );
   }
public void ExcludeClipRegion(PaintEventArgs e)
{
             
    // Create rectangle for region.
    Rectangle excludeRect = new Rectangle(100, 100, 200, 200);
             
    // Create region for exclusion.
    Region excludeRegion = new Region(excludeRect);
             
    // Set clipping region to exclude region.
    e.Graphics.ExcludeClip(excludeRegion);
             
    // Fill large rectangle to show clipping region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Blue), 0, 0, 300, 300);
}
Public Sub ExcludeClipRegion(ByVal e As PaintEventArgs)

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

    ' Create region for exclusion.
    Dim excludeRegion As New [Region](excludeRect)

    ' Set clipping region to exclude region.
    e.Graphics.ExcludeClip(excludeRegion)

    ' Fill large rectangle to show clipping region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Blue), 0, 0, _
    300, 300)
End Sub

備註

這個方法會從目前的剪輯區域排除 參數所 region 指定的區域,並將產生的區域指派給 Clip 這個 Graphics的屬性。

適用於

ExcludeClip(Rectangle)

來源:
Graphics.cs
來源:
Graphics.cs
來源:
Graphics.cs

更新這個 Graphics 的裁剪區域,以排除由 Rectangle 結構所指定的區域。

public:
 void ExcludeClip(System::Drawing::Rectangle rect);
public void ExcludeClip (System.Drawing.Rectangle rect);
member this.ExcludeClip : System.Drawing.Rectangle -> unit
Public Sub ExcludeClip (rect As Rectangle)

參數

rect
Rectangle

Rectangle 結構,指定要從裁剪區域排除的矩形。

範例

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

  • 建立 100 像素的 100 像素矩形,其左上角位於座標 (100,100) 。

  • 建立矩形所定義的區域。

  • 設定裁剪區域以排除矩形區域。

  • 以純藍色筆刷填入 300 像素的 300 像素矩形,其左上角位於座標 (0,0) 。

結果是藍色矩形,其右下角缺少正方形區域。

public:
   void ExcludeClipRectangle( PaintEventArgs^ e )
   {
      // Create rectangle for exclusion.
      Rectangle excludeRect = Rectangle(100,100,200,200);

      // Set clipping region to exclude rectangle.
      e->Graphics->ExcludeClip( excludeRect );

      // Fill large rectangle to show clipping region.
      e->Graphics->FillRectangle( gcnew SolidBrush( Color::Blue ), 0, 0, 300, 300 );
   }
public void ExcludeClipRectangle(PaintEventArgs e)
{
             
    // Create rectangle for exclusion.
    Rectangle excludeRect = new Rectangle(100, 100, 200, 200);
             
    // Set clipping region to exclude rectangle.
    e.Graphics.ExcludeClip(excludeRect);
             
    // Fill large rectangle to show clipping region.
    e.Graphics.FillRectangle(new SolidBrush(Color.Blue), 0, 0, 300, 300);
}
Public Sub ExcludeClipRectangle(ByVal e As PaintEventArgs)

    ' Create rectangle for exclusion.
    Dim excludeRect As New Rectangle(100, 100, 200, 200)

    ' Set clipping region to exclude rectangle.
    e.Graphics.ExcludeClip(excludeRect)

    ' Fill large rectangle to show clipping region.
    e.Graphics.FillRectangle(New SolidBrush(Color.Blue), 0, 0, _
    300, 300)
End Sub

備註

這個方法會從目前的剪輯區域排除 參數所 rect 指定的區域,並將產生的區域指派給 Clip 這個 Graphics的屬性。

適用於