InkOverlay.StrokesDeleted Event

InkOverlay.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 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.

using Microsoft.Ink;
//...
  theInkOverlay.Stroke += new InkCollectorStrokeEventHandler(theInkOverlay_Stroke);
  theInkOverlay.StrokesDeleted += new InkOverlayStrokesDeletedEventHandler(theInkOverlay_StrokesDeleted);
//...
  private void theInkOverlay_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 (theInkOverlay.EditingMode == InkOverlayEditingMode.Ink)
      {
          BackColor = Color.White;
      }
  }

  private void theInkOverlay_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 (theInkOverlay.Ink.Strokes.Count == 0 ||
          (theInkOverlay.Ink.Strokes.Count == 1 &&
           theInkOverlay.Ink.Strokes[0].DrawingAttributes.Transparency == 255))
      {
          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 theInkOverlay As InkOverlay
'...
    Private Sub theInkOverlay_Stroke(ByVal sender As Object, ByVal e As Microsoft.Ink.InkCollectorStrokeEventArgs) _
    Handles theInkOverlay.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 theInkOverlay.EditingMode = InkOverlayEditingMode.Ink Then
            BackColor = Color.White
        End If
    End Sub

    Private Sub theInkOverlay_StrokesDeleted(ByVal sender As Object, ByVal e As System.EventArgs) _
    Handles theInkOverlay.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 theInkOverlay.Ink.Strokes.Count = 0 Or _
           (theInkOverlay.Ink.Strokes.Count = 1 And _
            theInkOverlay.Ink.Strokes(0).DrawingAttributes.Transparency = 255) Then
           BackColor = Color.Gray
        End If
    End Sub

See Also