Share via


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);
}
public function get AutoRedraw () : boolean 
public function set AutoRedraw (value : boolean)

Property Value

Type: System.Boolean
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 notification. 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 OnPaint event handler to draw the ink yourself or handle the underlying control's Invalidate event to modify the InvalidateEventArgs object.

Examples

This example displays strokes in an InkCollector object by setting the AutoRedraw property to false, then manually drawing the ink. The Paint event handler for the control to which the InkCollector is attached checks the size of each stroke. If the stroke is smaller than 400 ink space units, the stroke appears blue.

Private Sub mInkObjectControl_Paint(ByVal sender As Object, ByVal e As PaintEventArgs)

    ' Check if AutoRedraw is off 
    ' mInkObject can be InkCollector, InkOverlay, or InkPicture 
    If Not mInkObject.AutoRedraw Then 

        ' Draw each stroke manually 
        For Each stroke As Stroke In mInkObject.Ink.Strokes
            ' See if this stroke is small 
            Dim strokeBounds As Rectangle = stroke.GetBoundingBox()
            If strokeBounds.Width < 400 And strokeBounds.Height < 400 Then 
                ' Change the drawing color to blue 
                Dim newAttributes As DrawingAttributes = stroke.DrawingAttributes.Clone()
                newAttributes.Color = Color.Blue
                ' Draw with these special drawing attributes
                mInkObject.Renderer.Draw(e.Graphics, stroke, newAttributes)
            Else 
                ' Draw stroke with its own drawing attributes
                mInkObject.Renderer.Draw(e.Graphics, stroke)
            End If 
        Next 
    End If 

End Sub
private void mInkObjectControl_Paint(object sender, PaintEventArgs e)
{
    // Check if AutoRedraw is off 
    // mInkObject can be InkCollector, InkOverlay, or InkPicture 
    if (!mInkObject.AutoRedraw)
    {
        // Draw each stroke manually 
        foreach (Stroke stroke in mInkObject.Ink.Strokes)
        {
            // See if this stroke is small
            Rectangle strokeBounds = stroke.GetBoundingBox();
            if (strokeBounds.Width < 400 && strokeBounds.Height < 400)
            {
                // Change the drawing color to blue
                DrawingAttributes newAttributes = stroke.DrawingAttributes.Clone();
                newAttributes.Color = Color.Blue;

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

}

Platforms

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

InkCollector Class

InkCollector Members

Microsoft.Ink Namespace

InkCollector.DynamicRendering

Ink

Renderer.Draw