Compartir a través de


InkPicture.Painting Event

InkPicture.Painting Event

Occurs before the InkPicture 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 InkPicture 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;
//...
  theInkPicture.Painting += new InkOverlayPaintedEventHandler(theInkPicture_Painting);
//...
  private void theInkPicture_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;
      theInkPicture_Painting.Ink.Strokes.ModifyDrawingAttributes(theDrawingAttributes);
  }
//...

[Visual Basic .NET]

This Microsoft® Visual Basic® .NET example shows how to add a Painting event handler to an InkPicture 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 theInkPicture As InkPicture
'...

    Private Sub theInkPicture_Painting(ByVal sender As Object, ByVal e As Microsoft.Ink.InkOverlayPaintingEventArgs)_
    Handles theInkPicture.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
        theInkPicture.Ink.Strokes.ModifyDrawingAttributes(theDrawingAttributes)
    End Sub
'...

See Also