移除 Stroke 物件或 Strokes 集合中超出給定矩形的部分。
命名空間: Microsoft.Ink
組件: Microsoft.Ink (在 Microsoft.Ink.dll 中)
語法
'宣告
Public Sub Clip ( _
r As Rectangle _
)
'用途
Dim instance As Ink
Dim r As Rectangle
instance.Clip(r)
public void Clip(
Rectangle r
)
public:
void Clip(
Rectangle r
)
public void Clip(
Rectangle r
)
public function Clip(
r : Rectangle
)
參數
- r
型別:System.Drawing.Rectangle
Stroke 物件或 Strokes 集合中超出的矩形部分都會被裁剪。
備註
r 參數是以筆墨空間座標指定的。
Ink 物件中超出矩形的筆墨部分都會刪除。基於這個原因,Clip 方法可能會在 Stroke 物件與矩形的交集點處,為 Stroke 物件新增點。
對 Ink 物件呼叫 Clip 方法後,Ink 物件的 Strokes 集合中每個 Stroke 物件的屬性可能會變更。例如,Stroke 物件從裁剪矩形區域中開始,離開裁剪矩形,然後返回裁剪矩形,則它會變成兩個 Stroke 物件,而且至少其中一個物件有新的 Id 屬性。除了這個行為之外,Ink 物件中的所有 Id 屬性即使經過變更,也一定會是唯一屬性。Stroke 物件的其他屬性也可能會進行類似變更。
在裁剪時,這個方法不會將畫筆寬度納入考量。只會裁剪實際的筆墨或筆劃資料。
對於 Stroke 物件或 Strokes 集合,Clip 方法會更新父物件 Ink。只要從 Ink 物件中移除筆墨,針對該 Ink 物件定義的任何 Stroke 物件或 Strokes 集合可能都會變成無效。
如需如何操作筆墨資料的詳細資訊,請參閱Ink Data。
範例
在這個範例中,會取得筆墨控制項的工作區 (Client Area)、將其轉換為 HIMETRIC 單位,然後再縮減 1500 單位的大小。接著會使用 Clip 方法,移除 Stroke 物件中超出矩形的部分。
' get the bottom right point of the client area for ink
' Note: InkOverlay.AttachedControl property must be set
Dim bottomRight As Point = New Point(mInkOverlay.AttachedControl.ClientSize)
' convert to HIMETRIC units
Using g As Graphics = mInkOverlay.AttachedControl.CreateGraphics()
mInkOverlay.Renderer.PixelToInkSpace(g, bottomRight)
End Using
' create a rectangle of the client area (HIMETRIC units)
Dim R As Rectangle = New Rectangle(0, 0, bottomRight.X, bottomRight.Y)
' shrink the rectangle by 1500
R.Inflate(-1500, -1500)
' clip the strokes to the rectangle
mInkOverlay.Ink.Clip(R)
mInkOverlay.AttachedControl.Invalidate()
// get the bottom right point of the client area for ink
// Note: InkOverlay.AttachedControl property must be set
Point bottomRight = new Point(mInkOverlay.AttachedControl.ClientSize);
// convert to HIMETRIC units
using (Graphics g = mInkOverlay.AttachedControl.CreateGraphics())
{
mInkOverlay.Renderer.PixelToInkSpace(g, ref bottomRight);
}
// create a rectangle of the client area (HIMETRIC units)
Rectangle R = new Rectangle(0, 0, bottomRight.X, bottomRight.Y);
// shrink the rectangle by 1500
R.Inflate(-1500, -1500);
// clip the strokes to the rectangle
mInkOverlay.Ink.Clip(R);
mInkOverlay.AttachedControl.Invalidate();
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
版本資訊
.NET Framework
支援版本:3.0