Share via


InkPicture.StrokesDeleting Event

Occurs before Stroke objects are deleted from the InkPicture control's Ink property.

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

Syntax

'Declaration
Public Event StrokesDeleting As InkOverlayStrokesDeletingEventHandler
'Usage
Dim instance As InkPicture
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

The event handler receives an argument of type InkOverlayStrokesDeletingEventArgs that contains 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 a user made, implemented by using the StrokesDeleting event. When the user clicks the MenuItem object, menuItemUndoDelete, the Stroke objects that were previously deleted are added back in.

[C#]

using Microsoft.Ink;
//...
  private Ink inkForDeletedStrokes;
//...
      theInkPicture.StrokesDeleting += new InkOverlayStrokesDeletingEventHandler(theInkPicture_StrokesDeleting);
//...
  private void theInkPicture_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.)
          theInkPicture.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 a user made, implemented by using the StrokesDeleting event. When the user clicks the MenuItem object, menuItemUndoDelete, the Stroke objects that were previously deleted are added back in.

[Visual Basic]

Imports Microsoft.Ink
'...
    Private inkForDeletedStrokes As Ink
    Private WithEvents theInkPicture As InkPicture
'...
    Private Sub theInkPicture_StrokesDeleting(ByVal sender As Object, _
    ByVal e As Microsoft.Ink.InkOverlayStrokesDeletingEventArgs) _
    Handles theInkPicture.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.)
            theInkPicture.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

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