Renderer.Draw Method (Graphics, Stroke)
Draws the Stroke object on the specified Graphics surface.
Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in Microsoft.Ink.dll)
Syntax
'Declaration
Public Sub Draw ( _
g As Graphics, _
stroke As Stroke _
)
'Usage
Dim instance As Renderer
Dim g As Graphics
Dim stroke As Stroke
instance.Draw(g, stroke)
public void Draw(
Graphics g,
Stroke stroke
)
public:
void Draw(
Graphics^ g,
Stroke^ stroke
)
public function Draw(
g : Graphics,
stroke : Stroke
)
Parameters
g
Type: System.Drawing.GraphicsThe Graphics object with which to draw.
stroke
Type: Microsoft.Ink.StrokeThe Stroke object 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.
Examples
In this example, a Stroke object is created in an Ink object. The stroke runs from the top left corner of the ink area to the bottom right corner. Once created, the stroke is displayed on the Panel associated with the InkOverlay object as well as on another panel. This is acomplished by calling the Draw method twice, passing different Graphics objects to the g parameter.
' get the bottom right point of the client area for ink
' Note: InkOverlay.AttachedControl property must be set
Dim bottomRight As Point = New Point(mInkOverlay.AttachedControl.ClientSize)
Using g1 As Graphics = mInkOverlay.AttachedControl.CreateGraphics()
' convert to HIMETRIC units
mInkOverlay.Renderer.PixelToInkSpace(g1, bottomRight)
' create the stroke
Dim strokePoints As Point() = New Point(1) {New Point(0), bottomRight}
Dim oneStroke As Stroke = mInkOverlay.Ink.CreateStroke(strokePoints)
' draw the stroke on the control attached to InkOverlay
mInkOverlay.Renderer.Draw(g1, oneStroke)
' now draw the stroke on another control also
Using g2 As Graphics = Me.panelForDraw.CreateGraphics()
mInkOverlay.Renderer.Draw(g2, oneStroke)
End Using
End Using
// get the bottom right point of the client area for ink
// Note: InkOverlay.AttachedControl property must be set
Point bottomRight = new Point(mInkOverlay.AttachedControl.ClientSize);
using (Graphics g1 = mInkOverlay.AttachedControl.CreateGraphics())
{
// convert to HIMETRIC units
mInkOverlay.Renderer.PixelToInkSpace(g1, ref bottomRight);
// create the stroke
Point[] strokePoints = new Point[2] { new Point(0), bottomRight };
Stroke oneStroke = mInkOverlay.Ink.CreateStroke(strokePoints);
// draw the stroke on the control attached to InkOverlay
mInkOverlay.Renderer.Draw(g1, oneStroke);
// now draw the stroke on another control also
using (Graphics g2 = this.panelForDraw.CreateGraphics())
{
mInkOverlay.Renderer.Draw(g2, oneStroke);
}
}
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