Share via


Ink.DeleteStrokes Method (Strokes)

Deletes the specified Strokes collection from the Ink object.

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

Syntax

'Declaration
Public Sub DeleteStrokes ( _
    strokes As Strokes _
)
'Usage
Dim instance As Ink
Dim strokes As Strokes

instance.DeleteStrokes(strokes)
public void DeleteStrokes (
    Strokes strokes
)
public:
void DeleteStrokes (
    Strokes^ strokes
)
public void DeleteStrokes (
    Strokes strokes
)
public function DeleteStrokes (
    strokes : Strokes
)
Not applicable.

Parameters

  • strokes
    The Strokes collection to delete.

Remarks

The Ink object renumbers the indices of the remaining Stroke objects in the Ink object if the Stroke objects that were deleted do not fall at the end of the Ink object's Strokes collection.

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

Note

A Strokes collection that points to an Ink.Strokes property become invalid when Stroke objects that are contained in the original collection are deleted from the Ink object. For example, if there is a named Strokes collection, theStrokesToo, that is based on an Ink object's Strokes property, theStrokes, and you call the DeleteStrokes method on theStrokes, then theStrokesToo becomes invalid.

To delete only one Stroke object at a time, call the DeleteStroke method.

Example

This C# example contains a sample function that deletes all of the Stroke objects in the Ink object, theInk, that are to the left of the Point parameter, thePoint, in pixel space. It then returns a count of the deleted Stroke objects.

public int DeleteStrokesOnLeft(
   System.Drawing.Point thePoint,
   Microsoft.Ink.Ink theInk,
   Microsoft.Ink.InkCollector theInkCollector,
   System.Drawing.Graphics g)
{
   // Convert the point from pixel space to ink space dimensions
   System.Drawing.Point ptLeft = thePoint;
   theInkCollector.Renderer.PixelToInkSpace(g, ref ptLeft);

   // Create a Strokes object to hold strokes to be deleted
   Strokes strokesToDelete = theInk.CreateStrokes();

   foreach (Stroke stroke in theInk.Strokes)
   {
      System.Drawing.Point[] ptStrokePoints = stroke.GetPoints();
      for (int i = 0; i < ptStrokePoints.Length; i++)
      {
         Point ptTest = ptStrokePoints[i];

         // If there is a point in this Stroke to the left of the parameter,
         if (ptTest.X < ptLeft.X)
         {
            // add this Stroke to the collection to delete
            strokesToDelete.Add(stroke);
         }
      }
   }
   if (0 < strokesToDelete.Count)
      theInk.DeleteStrokes(strokesToDelete);

   return strokesToDelete.Count;
}

This Microsoft Visual Basic.NET example contains a sample function that deletes all of the Stroke objects in the Ink object, theInk, that are to the left of the Point parameter, thePoint, in pixel space. It then returns a count of the deleted Stroke objects.

Public Function DeleteStrokesOnLeft( _
   ByVal thePoint As System.Drawing.Point, _
   ByRef theInk As Microsoft.Ink.Ink, _
   ByRef theInkCollector As Microsoft.Ink.InkCollector, _
   ByRef g As System.Drawing.Graphics _
)
   Dim i As Integer
   Dim ptTest As Point
   Dim ptLeft As Point
   Dim stroke As Stroke
   Dim strokesToDelete As Strokes
   Dim ptStrokePoints() As System.Drawing.Point

   ' Convert the left parameter from pixels to ink space
   ptLeft = thePoint
   theInkCollector.Renderer.PixelToInkSpace(g, ptLeft)

   ' Create a Strokes object to hold strokes to be deleted
   strokesToDelete = theInk.CreateStrokes()

   For Each stroke In theInk.Strokes
      ptStrokePoints = stroke.GetPoints()
      For i = 0 To ptStrokePoints.Length - 1
         ptTest = ptStrokePoints(i)

         ' If there is a point in this Stroke to the left of the parameter,
         If ptTest.X < ptLeft.X Then
            ' add this Stroke to the collection to delete
            strokesToDelete.Add(stroke)
         End If
      Next
   Next
   If 0 < strokesToDelete.Count Then
      theInk.DeleteStrokes(strokesToDelete)
   End If
   Return strokesToDelete.Count
End Function

Platforms

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

Ink Class
Ink Members
Microsoft.Ink Namespace
Strokes
Ink.DeleteStroke
Microsoft.Ink.Ink.CreateStroke
Microsoft.Ink.Ink.CreateStrokes