Graphics.Clip 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
public:
property System::Drawing::Region ^ Clip { System::Drawing::Region ^ get(); void set(System::Drawing::Region ^ value); };
public System.Drawing.Region Clip { get; set; }
member this.Clip : System.Drawing.Region with get, set
Public Property Clip As Region
属性值
一个 Region,它限定此 Graphics 当前可用的绘图区域。
示例
下面的代码示例演示如何使用 Clip 属性。 此示例旨在与 Windows 窗体 一起使用。 将代码粘贴到窗体中, SetAndFillClip
并在处理窗体 Paint 的事件时调用 方法,作为 e
PaintEventArgs传递。
private:
void SetAndFillClip( PaintEventArgs^ e )
{
// Set the Clip property to a new region.
e->Graphics->Clip = gcnew System::Drawing::Region( Rectangle(10,10,100,200) );
// Fill the region.
e->Graphics->FillRegion( Brushes::LightSalmon, e->Graphics->Clip );
// Demonstrate the clip region by drawing a string
// at the outer edge of the region.
e->Graphics->DrawString( "Outside of Clip", gcnew System::Drawing::Font( "Arial",12.0F,FontStyle::Regular ), Brushes::Black, 0.0F, 0.0F );
}
private void SetAndFillClip(PaintEventArgs e)
{
// Set the Clip property to a new region.
e.Graphics.Clip = new Region(new Rectangle(10, 10, 100, 200));
// Fill the region.
e.Graphics.FillRegion(Brushes.LightSalmon, e.Graphics.Clip);
// Demonstrate the clip region by drawing a string
// at the outer edge of the region.
e.Graphics.DrawString("Outside of Clip", new Font("Arial",
12.0F, FontStyle.Regular), Brushes.Black, 0.0F, 0.0F);
}
Private Sub SetAndFillClip(ByVal e As PaintEventArgs)
' Set the Clip property to a new region.
e.Graphics.Clip = New Region(New Rectangle(10, 10, 100, 200))
' Fill the region.
e.Graphics.FillRegion(Brushes.LightSalmon, e.Graphics.Clip)
' Demonstrate the clip region by drawing a string
' at the outer edge of the region.
e.Graphics.DrawString("Outside of Clip", _
New Font("Arial", 12.0F, FontStyle.Regular), _
Brushes.Black, 0.0F, 0.0F)
End Sub
注解
Region修改 属性返回Clip的对象不会影响后续使用 Graphics 对象的绘图。 若要更改剪辑区域,请将 Clip 属性值替换为新 Region 对象。 若要确定剪辑区域是否无限,请检索 Clip 属性并调用其 IsInfinite 方法。