InkOverlayStrokesDeletingEventArgs.StrokesToDelete Property

InkOverlayStrokesDeletingEventArgs.StrokesToDelete Property

Gets the Strokes collection deleted when the StrokesDeleting event fires.

Definition

Visual Basic .NET Public ReadOnly Property StrokesToDelete As Strokes
C# public Strokes StrokesToDelete { get; }
Managed C++ public: __property Strokes* get_StrokesToDelete();

Property Value

Microsoft.Ink.Strokes. The Strokes collection deleted when the StrokesDeleting event fires.

This property is read-only. This property has no default value.

Examples

[C#]

This C# example creates an undo mechanism for the last Strokes collection deleted during a StrokesDeleting event. When a user clicks the MenuItem Leave Site item, menuItemUndoDelete, the deleted Strokes collection is added back into the InkOverlay object, theInkOverlay.

using Microsoft.Ink;
  private Ink inkForDeletedStrokes;
//...
      theInkOverlay.StrokesDeleting +=
          new InkOverlayStrokesDeletingEventHandler(theInkOverlay_StrokesDeleting);
//...
  private void theInkOverlay_StrokesDeleting(object sender, InkOverlayStrokesDeletingEventArgs e)
  {
      // Store strokes for later undo.
      // You need to store them in a separate Ink object so that they don't get
      // completely deleted.
      inkForDeletedStrokes = new Ink();
      inkForDeletedStrokes.AddStrokesAtRectangle(e.StrokesToDelete,
          e.StrokesToDelete.GetBoundingBox());
  }

  private void menuItemUndoDelete_Click(object sender, System.EventArgs e)
  {
      if (inkForDeletedStrokes != null)
      {
          // Add strokes back.  (You need to use Ink.AddStrokesAtRectangle as opposed
          // to Strokes.Add because these are two different Ink objects.)
          theInkOverlay.Ink.AddStrokesAtRectangle(inkForDeletedStrokes.Strokes,
              inkForDeletedStrokes.Strokes.GetBoundingBox());

          inkForDeletedStrokes = null;

          // For best performance, you should Invalidate the rectangle created by the
          // bounding box (converted from ink space to pixel space).  For simplicity,
          // we will just refresh the entire control.
          Refresh();
      }
  }
//...

[Visual Basic .NET]

This Microsoft® Visual Basic® .NET example creates an undo mechanism for the last Strokes collection deleted during a StrokesDeleting event. When a user clicks the MenuItem Leave Site item, menuItemUndoDelete, the deleted Strokes collection is added back into the InkOverlay object, theInkOverlay.

Imports Microsoft.Ink
'...
    Private inkForDeletedStrokes As Ink
    Private WithEvents theInkOverlay As InkOverlay
'...
    Private Sub theInkOverlay_StrokesDeleting(ByVal sender As Object, _
    ByVal e As Microsoft.Ink.InkOverlayStrokesDeletingEventArgs) _
    Handles theInkOverlay.StrokesDeleting
        'Store strokes for later undo.
        'You need to store them in a separate Ink object so that they don't get
        'completely deleted.
        inkForDeletedStrokes = New Ink()
        inkForDeletedStrokes.AddStrokesAtRectangle(e.StrokesToDelete, _
            e.StrokesToDelete.GetBoundingBox())
    End Sub

    Private Sub MenuItemUndoDelete_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) _
    Handles MenuItemUndoDelete.Click
        If Not inkForDeletedStrokes Is Nothing Then
            'Add strokes back.  (You need to use Ink.AddStrokesAtRectangle as opposed
            'to Strokes.Add because these are two different Ink objects.)
            theInkOverlay.Ink.AddStrokesAtRectangle(inkForDeletedStrokes.Strokes, _
                    inkForDeletedStrokes.Strokes.GetBoundingBox())

            inkForDeletedStrokes = Nothing

            'For best performance, you should Invalidate the rectangle created by the
            'bounding box (converted from ink space to pixel space).  For simplicity,
            'we will just refresh the entire control.
            Refresh()
       End If
    End Sub

See Also