Region.MakeEmpty 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将此 Region 初始化为一个空内部。
public:
void MakeEmpty();
public void MakeEmpty ();
member this.MakeEmpty : unit -> unit
Public Sub MakeEmpty ()
示例
下面的代码示例演示如何使用 Region 构造函数和 MakeEmpty 方法。 此示例旨在与 Windows 窗体 一起使用。 Create窗体,并将以下代码粘贴到窗体中。 FillEmptyRegion
在窗体的事件Paint处理方法中调用 方法,作为 e
PaintEventArgs传递。
private:
void FillEmptyRegion( PaintEventArgs^ e )
{
// Create a region from a rectangle.
Rectangle originalRectangle = Rectangle(40,40,40,50);
System::Drawing::Region^ smallRegion = gcnew System::Drawing::Region( originalRectangle );
// Call MakeEmpty.
smallRegion->MakeEmpty();
// Fill the region in red and draw the original rectangle
// in black. Note there is nothing filled in.
e->Graphics->FillRegion( Brushes::Red, smallRegion );
e->Graphics->DrawRectangle( Pens::Black, originalRectangle );
}
private void FillEmptyRegion(PaintEventArgs e)
{
// Create a region from a rectangle.
Rectangle originalRectangle = new Rectangle(40, 40, 40, 50);
Region smallRegion = new Region(originalRectangle);
// Call MakeEmpty.
smallRegion.MakeEmpty();
// Fill the region in red and draw the original rectangle
// in black. Note there is nothing filled in.
e.Graphics.FillRegion(Brushes.Red, smallRegion);
e.Graphics.DrawRectangle(Pens.Black, originalRectangle);
}
Private Sub FillEmptyRegion(ByVal e As PaintEventArgs)
' Create a region from a rectangle.
Dim originalRectangle As New Rectangle(40, 40, 40, 50)
Dim smallRegion As New Region(originalRectangle)
' Call MakeEmpty.
smallRegion.MakeEmpty()
' Fill the region in red and draw the original rectangle
' in black. Note there is nothing filled in.
e.Graphics.FillRegion(Brushes.Red, smallRegion)
e.Graphics.DrawRectangle(Pens.Black, originalRectangle)
End Sub