InkPicture.StrokesDeleted Event

InkPicture.StrokesDeleted Event

Occurs after strokes have been deleted from the Ink property.

Definition

Visual Basic .NET Public Event StrokesDeleted As InkOverlayStrokesDeletedEventHandler
C# public event InkOverlayStrokesDeletedEventHandler StrokesDeleted;
Managed C++ public: __event InkOverlayStrokesDeletedEventHandler StrokesDeleted;

Remarks

The event handler receives an argument of type EventArgs Leave Site, which contains no data.

Examples

[C#]

This C# example demonstrates changing an InkPicture's background color to white when there are strokes, and changing it to gray when there are none. If you are deleting strokes with an eraser, you need to be aware that the movement of the eraser is considered a Stroke itself.

using Microsoft.Ink;
//...
  theInkPicture.Stroke += new InkCollectorStrokeEventHandler(theInkPicture_Stroke);
  theInkPicture.StrokesDeleted += new InkOverlayStrokesDeletedEventHandler(theInkPicture_StrokesDeleted);
//...
  private void theInkPicture_Stroke(object sender, InkCollectorStrokeEventArgs e)
  {
      // If you are in inking mode, change background to white.
      // (This event will also fire in Delete mode because the movement made by
      // the eraser is considered a stroke.)
      if (theInkPicture.EditingMode == InkOverlayEditingMode.Ink)
      {
          theInkPicture.BackColor = Color.White;
      }
  }

  private void theInkPicture_StrokesDeleted(object sender, System.EventArgs e)
  {
      // Change the background to gray if there are no strokes.
      // If the last stroke was deleted by an eraser, there will be one transparent
      // stroke, which is the stroke made by the eraser itself.
      if (theInkPicture.Ink.Strokes.Count == 0 ||
          (theInkPicture.Ink.Strokes.Count == 1 &&
           theInkPicture.Ink.Strokes[0].DrawingAttributes.Transparency == 255))
      {
          theInkPicture.BackColor = Color.Gray;
      }
  }
//...

[Visual Basic .NET]

This Microsoft® Visual Basic® .NET example demonstrates changing a control's background color to white when there are strokes, and changing it to gray when there are none. If you are deleting strokes with an eraser, you need to be aware that the movement of the eraser is considered a Stroke itself.

Imports Microsoft.Ink
'...
    Private WithEvents theInkPicture As InkPicture
'...
    Private Sub theInkPicturey_Stroke(ByVal sender As Object, ByVal e As Microsoft.Ink.InkCollectorStrokeEventArgs) _
    Handles theInkPicture.Stroke
        'If you are in inking mode, change background to white.
        '(This event will also fire in Delete mode because the movement made by
        'the eraser is considered a stroke.)
        If theInkPicture.EditingMode = InkOverlayEditingMode.Ink Then
            theInkPicture.BackColor = Color.White
        End If
    End Sub

    Private Sub theInkPicture_StrokesDeleted(ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles theInkPicture.StrokesDeleted
        'Change the background to gray if there are no strokes.
        'If the last stroke was deleted by an eraser, there will be one transparent
        'stroke, which is the stroke made by the eraser itself.
        If theInkPicture.Ink.Strokes.Count = 0 Or _
           (theInkPicture.Ink.Strokes.Count = 1 And _
            theInkPicture.Ink.Strokes(0).DrawingAttributes.Transparency = 255) Then
           theInkPicture.BackColor = Color.Gray
        End If
    End Sub

See Also