Share via


Strokes.Add Method (Stroke)

Adds a Stroke object to the Strokes collection.

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)

Syntax

'Declaration
Public Function Add ( _
    stroke As Stroke _
) As Integer
'Usage
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 function Add(
    stroke : Stroke
) : int

Parameters

Return Value

Type: System.Int32
This method always returns a value of -1.

Remarks

The Stroke object must already exist within the Ink object and cannot belong to another Ink object. In addition, this method does not copy or otherwise alter the Ink object, but merely adds this Stroke to the Strokes collection. If you call this method with a Stroke object that is already contained in the Strokes collection, the Stroke object will not be added again, and no exception will be raised.

Examples

In this example, a Stroke object is added to a newly created Strokes collection. This collection in turn is added to another Strokes collection. The Ink object passed to the example method is used to create new Strokes collections, and new Stroke objects. When you create a new Stroke object by calling the CreateStroke method, the newly created Stroke is automatically added to the main Strokes collection of the Ink object. In addtion, as shown in this example, the newly created Stroke object can be added to other Strokes collections.

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);
}

Platforms

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

Strokes Class

Strokes Members

Add Overload

Microsoft.Ink Namespace

Stroke

Strokes