Graphics.ExcludeClip 方法

定义

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

重载

ExcludeClip(Region)

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

ExcludeClip(Rectangle)

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

ExcludeClip(Region)

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 像素的 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 参数指定的区域,并将生成的区域分配给此 GraphicsClip 属性。

适用于

ExcludeClip(Rectangle)

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 像素的 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 参数指定的区域,并将生成的区域分配给此 GraphicsClip 属性。

适用于