Bagikan melalui


Ink.DeleteStroke Method

Ink.DeleteStroke Method

Deletes a Stroke object from the Ink object.

Definition

Visual Basic .NET Public Sub DeleteStroke( _
ByVal stroke As Stroke _
)
C# public void DeleteStroke(
Stroke stroke
);
Managed C++ public: void DeleteStroke(
Stroke *stroke
);

Parameters

stroke Microsoft.Ink.Stroke. The Stroke object to delete.

Exceptions

ArgumentException Leave Site: The parameter is not valid.
COMException Leave Site:
ObjectDisposedException Leave Site: The Ink object is disposed.

Remarks

This method deletes only a single Stroke object. To delete a Strokes collection, call the DeleteStrokes method.

This method can result in an error if called while the user is actively laying down ink.

Examples

[C#]

This C# example creates a sample method that uses a foreach loop to iterate through the Stroke objects contained in an Ink object, theInk. It then deletes any Stroke object that has more points than countOfPoints and returns the number of deleted Stroke objects.

public int DeleteLongerStrokes(int countOfPoints, Ink theInk)
{
    int countOfDeletedStrokes = 0;
    foreach (Stroke stroke in theInk.Strokes)
    {
        if (stroke.PacketCount > countOfPoints)
        {
            theInk.DeleteStroke(stroke);
            countOfDeletedStrokes++;
        }
    }
    return countOfDeletedStrokes;
}

[Visual Basic .NET]

This Microsoft® Visual Basic® .NET example creates a sample method that uses a For Each loop to iterate through the Stroke objects contained in an Ink object, theInk. It then deletes any Stroke object that has more points than countOfPoints and returns the number of deleted Stroke objects.

Public Function DeleteLongerStrokes(ByVal countOfPoints As Integer, _
ByRef theInk As Ink) As Integer
    Dim countOfDeletedStrokes As Integer
    Dim stroke As Stroke

    For Each stroke In theInk.Strokes
        If stroke.PacketCount > countOfPoints Then
            theInk.DeleteStroke(stroke)
            countOfDeletedStrokes = countOfDeletedStrokes + 1
        End If
    Next
    Return countOfDeletedStrokes
End Function

See Also