Compartilhar via


InkCollector.AutoRedraw Property

InkCollector.AutoRedraw Property

Gets or sets a value that specifies whether the InkCollector object repaints the ink when the window is invalidated.

Definition

Visual Basic .NET Public Property AutoRedraw As Boolean
C# public bool AutoRedraw { get; set; }
Managed C++ public: __property bool* get_AutoRedraw();
public: __property void set_AutoRedraw(bool*);

Property Value

System.Boolean. Value that specifies whether the InkCollector object repaints the ink when the window is invalidated.

This property is read/write.

true Default. The InkCollector object repaints the ink when the window is invalidated.
false The InkCollector object does not repaint the ink when the window is invalidated.

Exceptions

ObjectDisposedException Leave Site:

Remarks

The value for AutoRedraw specifies whether or not the Ink object currently associated with InkCollector object is automatically redrawn when the window associated with the InkCollector object receives a Paint Leave Site event. For example, if set to true, when you minimize the window and then restore it, the ink is automatically redrawn. If set to false, when you minimize the window and then restore it, the ink disappears from view.

When AutoRedraw is false, the ink appears while inking unless the DynamicRendering property is false.

When your application is performing custom rendering or when your application is sensitive to painting issues, you can handle the repainting yourself and set the AutoRedraw property to false for the InkPicture control. In that case add a delegate to the underlying control's OnPaint Leave Site event handler to draw the ink yourself or handle the underlying control's Invalidate Leave Site event to modify the InvalidateEventArgs Leave Site object.

Examples

[C#]

This C# example displays strokes in an InkCollector by setting the AutoRedraw property to false and then manually drawing the ink. An InkCollector, theInkCollector, is attached to a form, Form1. The Paint Leave Site event handler checks the size of each stroke. If the stroke is smaller than 300 ink space units, the stroke appears gray.

private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
    // Check if AutoRedraw is off
    if (!theInkCollector.AutoRedraw)
    {
        // Draw each stroke manually
        foreach (Stroke stroke in theInkCollector.Ink.Strokes)
        {
            // See if this stroke is small
            Rectangle strokeBounds = stroke.GetBoundingBox();
            if (strokeBounds.Width < 300 && strokeBounds.Height < 300)
            {
                 // Change the drawing color to gray
                 DrawingAttributes selectedAttributes = stroke.DrawingAttributes.Clone();
                 selectedAttributes.Color = Color.Gray;

                 // Draw with these special drawing attributes
                 theInkCollector.Renderer.Draw(e.Graphics, stroke, selectedAttributes);
            }
            else
            {
                 // Draw stroke with its own drawing attributes
                 theInkCollector.Renderer.Draw(e.Graphics, stroke);
            }
        }
    }
}
            

[VB.NET]

This Microsoft® Visual Basic® .NET example displays strokes in an InkCollector by setting the AutoRedraw property to false and then manually drawing the ink. An InkCollector, theInkCollector, is attached to a form, Form1. The Paint Leave Site event handler checks the size of each stroke. If the stroke is smaller than 300 ink space units, the stroke appears gray.

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs)
Handles MyBase.Paint
    'Check if AutoRedraw is off
    If theInkCollector.AutoRedraw = False Then
        'Draw each stroke manually
        Dim theStroke As Stroke
        For Each theStroke In theInkCollector.Ink.Strokes
            'See if this stroke is small
            Dim strokeBounds As Rectangle = theStroke.GetBoundingBox()
            If strokeBounds.Width < 300 And strokeBounds.Height < 300 Then
                'Change the drawing color to gray
                Dim selectedAttributes As DrawingAttributes = theStroke.DrawingAttributes.Clone()
                selectedAttributes.Color = Color.Gray

                'Draw with these special drawing attributes
                theInkCollector.Renderer.Draw(e.Graphics, theStroke, selectedAttributes)
            Else
                'Draw stroke with its own drawing attributes
                theInkCollector.Renderer.Draw(e.Graphics, theStroke)
            End If
        Next
    End If
End Sub
            

See Also