將這個
Graphics 的裁剪區域,設定為目前裁剪區域和指定的
Graphics 之
Clip 屬性的指定組合作業結果。
命名空間: System.Drawing
組件: System.Drawing (在 system.drawing.dll 中)
Public Sub SetClip ( _
g As Graphics, _
combineMode As CombineMode _
)
Dim instance As Graphics
Dim g As Graphics
Dim combineMode As CombineMode
instance.SetClip(g, combineMode)
public void SetClip (
Graphics g,
CombineMode combineMode
)
public:
void SetClip (
Graphics^ g,
CombineMode combineMode
)
public void SetClip (
Graphics g,
CombineMode combineMode
)
public function SetClip (
g : Graphics,
combineMode : CombineMode
)
參數
- g
Graphics,指定要組合的裁剪區域。
- combineMode
CombineMode 列舉型別的成員,指定要使用的組合作業。
下列程式碼範例的設計是供配合 Windows Form 使用,它需要 PaintEventArgse (Paint 事件處理常式的參數) 以及 thisForm (此範例的 Form)。該程式碼會執行下列動作:
-
從範例的 thisFormForm 建立暫時的 Graphics。
-
將暫時 Graphics 的裁剪區域設定為小方形。
-
使用 Replace 成員,將表單之圖形物件的裁剪區域更新為新 Graphics 的裁剪區域。
-
使用實心黑色筆刷填滿大矩形。
結果會是小的、填滿的黑色方形。
Public Sub SetClipGraphicsCombine(ByVal e As PaintEventArgs)
' Create temporary graphics object and set its clipping region.
Dim newGraphics As Graphics = Me.CreateGraphics()
newGraphics.SetClip(New Rectangle(0, 0, 100, 100))
' Update clipping region of graphics to clipping region of new
' graphics.
e.Graphics.SetClip(newGraphics, CombineMode.Replace)
' Fill rectangle to demonstrate clip region.
e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
500, 300)
' Release new graphics.
newGraphics.Dispose()
End Sub
public void SetClipGraphicsCombine(PaintEventArgs e)
{
// Create temporary graphics object and set its clipping region.
Graphics newGraphics = this.CreateGraphics();
newGraphics.SetClip(new Rectangle(0, 0, 100, 100));
// Update clipping region of graphics to clipping region of new
// graphics.
e.Graphics.SetClip(newGraphics, CombineMode.Replace);
// Fill rectangle to demonstrate clip region.
e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
// Release new graphics.
newGraphics.Dispose();
}
Windows 98、 Windows 2000 SP4、 Windows Millennium Edition、 Windows Server 2003、 Windows XP Media Center Edition、 Windows XP Professional x64 Edition、 Windows XP SP2、 Windows XP Starter Edition
.NET Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱系統需求一節的內容。
.NET Framework
支援版本:2.0、1.1、1.0