Graphics.ExcludeClip 方法

定义

更新此 Graphics 的剪辑区域,以排除 Rectangle 结构所指定的区域。

重载

ExcludeClip(Region)

更新此 Graphics 的剪辑区域,以排除 Region 所指定的区域。

ExcludeClip(Rectangle)

更新此 Graphics 的剪辑区域,以排除 Rectangle 结构所指定的区域。

ExcludeClip(Region)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
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 窗体 一起使用,它需要 PaintEventArgse,它是 事件处理程序的Paint一个参数。 此代码执行以下操作:

  • 创建一个 100 像素 x 100 像素矩形,其左上角位于坐标 (100,100) 。

  • 设置剪裁区域以排除矩形。

  • 使用纯蓝色画笔填充 300 像素 x 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)

Source:
Graphics.cs
Source:
Graphics.cs
Source:
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 窗体 一起使用,它需要 PaintEventArgse,它是 事件处理程序的Paint一个参数。 此代码执行以下操作:

  • 创建一个 100 像素 x 100 像素矩形,其左上角位于坐标 (100,100) 。

  • 创建由矩形定义的区域。

  • 设置剪裁区域以排除矩形区域。

  • 使用纯蓝色画笔填充 300 像素 x 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的 属性。

适用于