Aracılığıyla paylaş


InkPicture.AutoRedraw Property

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

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

Syntax

'Declaration
<BrowsableAttribute(True)> _
Public Property AutoRedraw As Boolean
'Usage
Dim instance As InkPicture 
Dim value As Boolean 

value = instance.AutoRedraw

instance.AutoRedraw = value
[BrowsableAttribute(true)]
public bool AutoRedraw { get; set; }
[BrowsableAttribute(true)]
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
Value that specifies whether the InkPicture control repaints the ink when the window is invalidated.

Value

Meaning

true

The InkPicture control repaints the ink when the window is invalidated.

false

The InkPicture control does not repaint the ink when the window is invalidated.

Remarks

The value for AutoRedraw specifies whether or not the Ink object currently associated with InkPicture control is automatically redrawn when the window associated with the InkPicture control receives a Paint notification. 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 InkPicture control's OnPainted event handler to draw the ink yourself or handle the inherited Invalidate event to modify the InvalidateEventArgs object.

Examples

This example displays strokes in an InkPicture control by setting the AutoRedraw property to false, then manually drawing the ink. The Paint event handler for the InkPicture control 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

InkPicture Class

InkPicture Members

Microsoft.Ink Namespace

InkPicture.OnPainted

InkPicture.DynamicRendering

Other Resources

System.Windows.Forms.Control.Invalidate Method