Bagikan melalui


Renderer.Draw Method (Graphics, Strokes)

Draws the Strokes collection on the specified Graphics surface.

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

Syntax

'Declaration
Public Sub Draw ( _
    g As Graphics, _
    strokes As Strokes _
)
'Usage
Dim instance As Renderer 
Dim g As Graphics 
Dim strokes As Strokes

instance.Draw(g, strokes)
public void Draw(
    Graphics g,
    Strokes strokes
)
public:
void Draw(
    Graphics^ g, 
    Strokes^ strokes
)
public function Draw(
    g : Graphics, 
    strokes : Strokes
)

Parameters

Remarks

Note

Use the appropriate overload that accepts a Graphics object instead of the one that accepts an IntPtr whenever possible.

The pen width is adjusted appropriately, based on how you use SetViewTransform method. Specifically, the pen width is multiplied (or scaled) by the square root of the determinant of the view transform.

Note

If you have not set the pen width explicitly, it is 53 by default. You must multiply the pen width by the square root of the determinant to yield the correct bounding box. The height and width of the bounding box are expanded by half this amount in each direction.

For example, consider that the pen width is 53, the square root of the determinant is 50, and the bounding box is (0,0,1000,1000). The pen width adjustment to the bounding box in each direction is calculated as (53*50)/2, and the right and bottom sides are incremented by one. This results in a rendered bounding box of (-1325,-1325,2326,2326).

The Renderer object forces the viewport and window origins to 0,0. Any existing settings are saved and restored, but are not used by the Renderer. To perform scrolling, use the Renderer object's GetViewTransform and GetObjectTransform methods.

Examples

In this example, the entire Strokes collection from an Ink object associated with an InkOverlay object is displayed on a Panel other than the one associated with the InkOverlay object itself. This is acomplished by calling the Draw method, passing to the g parameter a different Graphics object than the one associated with the InkOverlay object.

' Access to the Ink.Strokes property returns a copy of the Strokes object. 
' This copy must be implicitly (via using statement) or explicitly 
' disposed of in order to avoid a memory leak. 
Using allStrokes As Strokes = mInkOverlay.Ink.Strokes
    ' get a graphics object for another panel 
    Using g As Graphics = Me.panelForDraw.CreateGraphics()
        ' get a Renderer object. We could have used 
        ' mInkOverlay.Renderer, this is another way 
        Dim R As Renderer = New Renderer()
        ' draw the strokes
        R.Draw(g, allStrokes)
    End Using 
End Using
// Access to the Ink.Strokes property returns a copy of the Strokes object. 
// This copy must be implicitly (via using statement) or explicitly 
// disposed of in order to avoid a memory leak. 
using (Strokes allStrokes = mInkOverlay.Ink.Strokes)
{
    // get a graphics object for another panel 
    using (Graphics g = this.panelForDraw.CreateGraphics())
    {
        // get a Renderer object. We could have used 
        // mInkOverlay.Renderer, this is another way
        Renderer R = new Renderer();
        // draw the strokes
        R.Draw(g, allStrokes);
    }
}

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

Renderer Class

Renderer Members

Draw Overload

Microsoft.Ink Namespace

Renderer.SetViewTransform

DrawingAttributes

Strokes

Stroke