共用方式為


Strokes.Add 方法 (Stroke)

Stroke 物件加入至 Strokes 集合。

命名空間:  Microsoft.Ink
組件:  Microsoft.Ink (在 Microsoft.Ink.dll 中)

語法

'宣告
Public Function Add ( _
    stroke As Stroke _
) As Integer
'用途
Dim instance As Strokes
Dim stroke As Stroke
Dim returnValue As Integer

returnValue = instance.Add(stroke)
public int Add(
    Stroke stroke
)
public:
int Add(
    Stroke^ stroke
)
public int Add(
    Stroke stroke
)
public function Add(
    stroke : Stroke
) : int

參數

傳回值

型別:System.Int32
這個方法一定會傳回 -1 這個值。

備註

Stroke 物件必須已存在於 Ink 物件中,而且不能屬於另一個 Ink 物件。此外,這個方法也不會複製或改變 Ink 物件,而是只將這個 Stroke 加入至 Strokes 集合。如果使用已包含於 Strokes 集合中的 Stroke 物件呼叫這個方法,並不會重新加入 Stroke 物件,也不會引發例外狀況。

範例

在這個範例中,會將 Stroke 物件加入至剛建立的 Strokes 集合。接著,再將這個集合加入至另一個 Strokes 集合。傳遞至範例方法的 Ink 物件是用來建立新的 Strokes 集合和新的 Stroke 物件。藉由呼叫 CreateStroke 方法建立新的 Stroke 物件時,剛建立的 Stroke 會自動加入至 Ink 物件的主要 Strokes() 集合。此外,如這個範例所示,剛建立的 Stroke 物件也可以加入至其他 Strokes 集合。

Private Sub AddStrokes(ByVal mInk As Ink)
    ' create a new Strokes collection
    Dim newStrokes1 As Strokes = mInk.CreateStrokes()
    ' create a new Stroke
    Dim points As Point() = {New Point(500, 500), New Point(500, 2500)}
    Dim newStroke As Stroke = mInk.CreateStroke(points)
    ' add the new Stroke to the Strokes collection
    newStrokes1.Add(newStroke)
    ' create another Strokes collection
    Dim newStrokes2 As Strokes = mInk.CreateStrokes()
    ' add the first Strokes collection to the second Strokes collection
    newStrokes2.Add(newStrokes1)
End Sub
private void AddStrokes(Ink mInk)
{ 
    // create a new Strokes collection
    Strokes newStrokes1 = mInk.CreateStrokes();
    // create a new Stroke
    Point[] points = { new Point(500, 500), new Point(500, 2500) };
    Stroke newStroke = mInk.CreateStroke(points);
    // add the new Stroke to the Strokes collection
    newStrokes1.Add(newStroke);
    // create another Strokes collection
    Strokes newStrokes2 = mInk.CreateStrokes();
    // add the first Strokes collection to the second Strokes collection
    newStrokes2.Add(newStrokes1);
}

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求

版本資訊

.NET Framework

支援版本:3.0

請參閱

參考

Strokes 類別

Strokes 成員

Add 多載

Microsoft.Ink 命名空間

Stroke

Strokes