Compartir a través de


InkPicture.Painting Event

Occurs before the InkPicture control redraws itself.

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

Syntax

'Declaration
Public Event Painting As InkOverlayPaintingEventHandler
'Usage
Dim instance As InkPicture
Dim handler As InkOverlayPaintingEventHandler

AddHandler instance.Painting, handler
public event InkOverlayPaintingEventHandler Painting
public:
event InkOverlayPaintingEventHandler^ Painting {
    void add (InkOverlayPaintingEventHandler^ value);
    void remove (InkOverlayPaintingEventHandler^ value);
}
/** @event */
public void add_Painting (InkOverlayPaintingEventHandler value)

/** @event */
public void remove_Painting (InkOverlayPaintingEventHandler 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 InkOverlayPaintingEventArgs that contains data about this event.

When you create an InkOverlayPaintingEventHandler 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 invokes a Painting event handler that assigns random values to the DrawingAttributes object's Color and Width properties before the ink is painted.

[C#]

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);
  }
//...

This Microsoft® Visual Basic® .NET example invokes a Painting event handler that assigns random values to the DrawingAttributes object's Color and Width properties before the ink is painted.

[Visual Basic]

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

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
InkOverlayPaintingEventArgs
InkPicture.Painted