Graphics.ExcludeClip 方法

定义

更新此 Graphics 的剪辑区域,以排除 Rectangle 结构所指定的区域。Updates the clip region of this Graphics to exclude the area specified by a Rectangle structure.

重载

ExcludeClip(Region)

更新此 Graphics 的剪辑区域,以排除 Region 所指定的区域。Updates the clip region of this Graphics to exclude the area specified by a Region.

ExcludeClip(Rectangle)

更新此 Graphics 的剪辑区域,以排除 Rectangle 结构所指定的区域。Updates the clip region of this Graphics to exclude the area specified by a Rectangle structure.

ExcludeClip(Region)

更新此 Graphics 的剪辑区域,以排除 Region 所指定的区域。Updates the clip region of this Graphics to exclude the area specified by a 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,它指定要从剪辑区域排除的区域。Region that specifies the region to exclude from the clip region.

示例

下面的代码示例旨在与 Windows 窗体一起使用,并且它需要作为 PaintEventArgs e Paint 事件处理程序的参数。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 此代码执行以下操作:The code performs the following actions:

  • 创建一个100像素 x 100 像素的矩形,该矩形的左上角位于坐标 (100,100) 。Creates a 100 pixel by 100 pixel rectangle whose upper-left corner is at the coordinate (100, 100).

  • 将剪辑区域设置为排除矩形。Sets the clipping region to exclude the rectangle.

  • 填充300像素 x 300 像素的矩形,该矩形的左上角位于坐标 (0,0) ,具有纯色的蓝色画笔。Fills a 300 pixel by 300 pixel rectangle whose upper-left corner is at the coordinate (0, 0) with a solid blue brush.

结果是蓝色矩形,其右下角缺少正方形区。The result is a blue rectangle with a square area toward its lower-right corner missing.

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 此的属性 GraphicsThis method excludes the area specified by the region parameter from the current clip region and assigns the resulting area to the Clip property of this Graphics.

适用于

ExcludeClip(Rectangle)

更新此 Graphics 的剪辑区域,以排除 Rectangle 结构所指定的区域。Updates the clip region of this Graphics to exclude the area specified by a Rectangle structure.

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 结构,它指定要从剪辑区域排除的矩形。Rectangle structure that specifies the rectangle to exclude from the clip region.

示例

下面的代码示例旨在与 Windows 窗体一起使用,并且它需要作为 PaintEventArgs e Paint 事件处理程序的参数。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 此代码执行以下操作:The code performs the following actions:

  • 创建一个100像素 x 100 像素的矩形,该矩形的左上角位于坐标 (100,100) 。Creates a 100 pixel by 100 pixel rectangle whose upper-left corner is at the coordinate (100, 100).

  • 创建矩形定义的区域。Creates a region defined by the rectangle.

  • 将剪辑区域设置为排除矩形区域。Sets the clipping region to exclude the rectangular region.

  • 填充300像素 x 300 像素的矩形,该矩形的左上角位于坐标 (0,0) ,具有纯色的蓝色画笔。Fills a 300 pixel by 300 pixel rectangle whose upper-left corner is at the coordinate (0, 0) with a solid blue brush.

结果是一个蓝色矩形,其右下角附近缺少正方形区域。The result is a blue rectangle with a square region toward its lower-right corner missing.

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 此的属性 GraphicsThis method excludes the area specified by the rect parameter from the current clip region and assigns the resulting area to the Clip property of this Graphics.

适用于