Graphics.ResetClip 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将此 Graphics 的剪辑区域重置为无限区域。
public:
void ResetClip();
public void ResetClip ();
member this.ResetClip : unit -> unit
Public Sub ResetClip ()
示例
下面的代码示例设计用于 Windows 窗体,它需要 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 绘制的项目。