Share via


InkOverlay.StrokesDeleting Event

Occurs before strokes are deleted from the Ink property.

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

Syntax

'Declaration
Public Event StrokesDeleting As InkOverlayStrokesDeletingEventHandler
'Usage
Dim instance As InkOverlay
Dim handler As InkOverlayStrokesDeletingEventHandler

AddHandler instance.StrokesDeleting, handler
public event InkOverlayStrokesDeletingEventHandler StrokesDeleting
public:
event InkOverlayStrokesDeletingEventHandler^ StrokesDeleting {
    void add (InkOverlayStrokesDeletingEventHandler^ value);
    void remove (InkOverlayStrokesDeletingEventHandler^ value);
}
/** @event */
public void add_StrokesDeleting (InkOverlayStrokesDeletingEventHandler value)

/** @event */
public void remove_StrokesDeleting (InkOverlayStrokesDeletingEventHandler value)
In JScript, you can handle the events defined by a class, but you cannot define your own.
Not applicable.

Remarks

This event fires when you call either the Ink.DeleteStroke or the Microsoft.Ink.Ink.DeleteStrokes method for ink attached to an InkOverlay object.

The event handler receives an argument of type InkOverlayStrokesDeletingEventArgs containing data about this event.

When you create an InkOverlayStrokesDeletingEventHandler delegate, you identify the method that handles the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For performance reasons, the default event interest is off but is turned on automatically if you add an event handler.

Example

This C# example is an undo mechanism for the last delete that you made. The example uses the StrokesDeleting event. When a user clicks the MenuItemMenuItem, menuItemUndoDelete, the Stroke objects that were previously deleted are added back to 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 you are dealing with 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();
      }
  }
//...

This Microsoft Visual Basic .NET example is an undo mechanism for the last delete that you made. The example uses the StrokesDeleting event. When a user clicks the MenuItemMenuItem, menuItemUndoDelete, the Stroke objects that were previously deleted are added back to 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 you are dealing with 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

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

InkOverlay Class
InkOverlay Members
Microsoft.Ink Namespace
InkOverlay.Ink
InkOverlay.StrokesDeleted
InkOverlayStrokesDeletingEventArgs