Freigeben über


InkCollector.AutoRedraw Property

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

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

Syntax

'Declaration
Public Property AutoRedraw As Boolean
'Usage
Dim instance As InkCollector
Dim value As Boolean

value = instance.AutoRedraw

instance.AutoRedraw = value
public bool AutoRedraw { get; set; }
public:
property bool AutoRedraw {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_AutoRedraw ()

/** @property */
public void set_AutoRedraw (boolean value)
public function get AutoRedraw () : boolean

public function set AutoRedraw (value : boolean)
Not applicable.

Property Value

true if the InkCollector object repaints the ink when the window is invalidated; otherwise, false.

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 event. For example, if AutoRedraw is set to true, the ink is automatically redrawn when you minimize the window and then restore it. If set to false, when you minimize the window and 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 OnPaintOnPaint event handler to draw the ink yourself or handle the underlying control's Invalidate event to modify the InvalidateEventArgsInvalidateEventArgs object.

Example

This C# example displays strokes in an InkCollector by setting the AutoRedraw property to false, then manually drawing the ink. An InkCollector, theInkCollector, is attached to a form, Form1. The Paint 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);
            }
        }
    }
}

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

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

InkCollector Class
InkCollector Members
Microsoft.Ink Namespace
InkCollector.DynamicRendering
Ink
Microsoft.Ink.Renderer.Draw