Freigeben über


InkOverlay.Painting Event

InkOverlay.Painting Event

Occurs before the InkOverlay object redraws itself.

Definition

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

Remarks

The event handler receives an argument of type InkOverlayPaintingEventArgs that contains data about this event.

When you create an InkOverlayPaintingEventHandler delegate, you identify the method that will handle 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.

Examples

[C#]

This C# example shows how to add a Painting event handler to an InkOverlay object. The Painting event handler is invoked before the Paint event begins, and causes the Color and Width DrawingAttributes to be randomized before the ink is painted.

using Microsoft.Ink;
//...
  theInkOverlay.Painting += new InkOverlayPaintedEventHandler(inkOverlay_Painting);
//...
  private void inkOverlay_Painting(object sender, InkOverlayPaintingEventArgs e)
  {
      DrawingAttributes theDrawingAttributes = new DrawingAttributes();
      Random randomGenerator = new Random();
      theDrawingAttributes.Color = Color.FromArgb(randomGenerator.Next(255),
          randomGenerator.Next(255), randomGenerator.Next(255));
      theDrawingAttributes.Width = randomGenerator.Next(240) + 30;
      theInkOverlay.Ink.Strokes.ModifyDrawingAttributes(theDrawingAttributes);
  }
//...

[Visual Basic .NET]

This Microsoft® Visual Basic® .NET example shows how to add a Painting event handler to an InkOverlay object. The Painting event handler is invoked before the Paint event begins, and causes the Color and Width DrawingAttributes to be randomized before the ink is painted.

Imports Microsoft.Ink
'...
    Private WithEvents theInkOverlay As InkOverlay
'...

    Private Sub theInkOverlay_Painting(ByVal sender As Object, ByVal e As Microsoft.Ink.InkOverlayPaintingEventArgs)_
    Handles theInkOverlay.Painting
        Dim theDrawingAttributes As New DrawingAttributes()
        Dim randomGenerator As New Random()
        theDrawingAttributes.Color = Color.FromArgb(randomGenerator.Next(255), _
                randomGenerator.Next(255), randomGenerator.Next(255))
        theDrawingAttributes.Width = randomGenerator.Next(240) + 30
        theInkOverlay.Ink.Strokes.ModifyDrawingAttributes(theDrawingAttributes)
    End Sub
'...

See Also