Bagikan melalui


Renderer.Draw Method (IntPtr, Strokes)

Draws the Strokes collection on the device context whose handle is passed in.

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

Syntax

'Declaration
<PermissionSetAttribute(SecurityAction.InheritanceDemand, Name := "FullTrust")> _
<UIPermissionAttribute(SecurityAction.Demand, Window := UIPermissionWindow.SafeTopLevelWindows)> _
<SecurityPermissionAttribute(SecurityAction.Demand, UnmanagedCode := True)> _
Public Sub Draw ( _
    hdc As IntPtr, _
    strokes As Strokes _
)
'Usage
Dim instance As Renderer 
Dim hdc As IntPtr 
Dim strokes As Strokes

instance.Draw(hdc, strokes)
[PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
[UIPermissionAttribute(SecurityAction.Demand, Window = UIPermissionWindow.SafeTopLevelWindows)]
[SecurityPermissionAttribute(SecurityAction.Demand, UnmanagedCode = true)]
public void Draw(
    IntPtr hdc,
    Strokes strokes
)
[PermissionSetAttribute(SecurityAction::InheritanceDemand, Name = L"FullTrust")]
[UIPermissionAttribute(SecurityAction::Demand, Window = UIPermissionWindow::SafeTopLevelWindows)]
[SecurityPermissionAttribute(SecurityAction::Demand, UnmanagedCode = true)]
public:
void Draw(
    IntPtr hdc, 
    Strokes^ strokes
)
public function Draw(
    hdc : IntPtr, 
    strokes : Strokes
)

Parameters

  • hdc
    Type: System.IntPtr

    The handle of the device context on which to draw.

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.

Security noteSecurity Note:

If using under partial trust, this method requires SecurityPermissionFlag.UnmanagedCode permission in addition to the permissions required by InkCollector. For more information about security issues and partial trust, see Security and Trust.

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 hdc parameter a different device context handle 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()
        ' get the handle to the device context 
        Dim hdc As IntPtr = g.GetHdc()
        ' draw the strokes
        R.Draw(hdc, allStrokes)
        ' release the handle to the device context
        g.ReleaseHdc(hdc)
    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();
        // get the handle to the device context
        IntPtr hdc = g.GetHdc();
        // draw the strokes
        R.Draw(hdc, allStrokes);
        // release the handle to the device context
        g.ReleaseHdc();
    }
}

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