InkOverlay.Draw Method
Sets a rectangle in which to redraw the ink within the InkOverlay object.
Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in Microsoft.Ink.dll)
Syntax
'Declaration
Public Sub Draw ( _
rDrawRect As Rectangle _
)
'Usage
Dim instance As InkOverlay
Dim rDrawRect As Rectangle
instance.Draw(rDrawRect)
public void Draw(
Rectangle rDrawRect
)
public:
void Draw(
Rectangle rDrawRect
)
public function Draw(
rDrawRect : Rectangle
)
Parameters
rDrawRect
Type: System.Drawing.RectangleThe rectangle in which to redraw the ink, in pixel coordinates.
Remarks
When the rDrawRect parameter is nulla null reference (Nothing in Visual Basic) (Nothing in Microsoft Visual Basic .NET), the entire window is redrawn.
A good use of this method is to redraw strokes that have been programmically changed. You can also call the Control.Invalidate method, but this causes a redrawing off all of the InkOverlay object's strokes. You can also call the Renderer.Draw method for this purpose, but the Renderer object is not able to draw any strokes as selected because it has no knowledge of which strokes are in the Selection collection.
Note
The AutoRedraw property must be set to true for the drawing to occur.
Examples
This C# example is a method that changes the color of all the strokes in a Strokes collection that belong to the Ink object associated with an InkOverlay object, theInkOverlay. Changing the DrawingAttributes property of a Stroke object is not automatically and immediately visible. You can call the Invalidate or Refresh method on the control associated with theInkOverlay, but this causes a redrawing of all the Stroke objects in theInkOverlay. To achieve better performance, use the Draw method on the bounding box of the Strokes collection. Note that this means converting the bounding box from ink space coordinates to pixel coordinates.
private void ChangeColor(Strokes theStrokes, Color newColor)
{
// Change the color of theStrokes
foreach (Stroke stroke in theStrokes)
{
stroke.DrawingAttributes.Color = newColor;
}
// Convert bounding box to pixel coordinates
Graphics g = CreateGraphics();
Rectangle strokesBounds = theStrokes.GetBoundingBox();
Point topLeft = strokesBounds.Location;
Point bottomRight = strokesBounds.Location + strokesBounds.Size;
theInkOverlay.Renderer.InkSpaceToPixel(g, ref topLeft);
theInkOverlay.Renderer.InkSpaceToPixel(g, ref bottomRight);
g.Dispose()
strokesBounds = new Rectangle(topLeft,
new Size(bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y));
// Redraw the strokes
theInkOverlay.Draw(strokesBounds);
}
This Visual Basic .NET example is a method that changes the color of all the strokes in a Strokes collection belonging to the Ink object associated with an InkOverlay object, theInkOverlay. Changing the DrawingAttributes property of a Stroke object is not automatically and immediately visible. You can call the Invalidate or Refresh method on the control associated with theInkOverlay, but this causes a redrawing of all the Stroke objects in theInkOverlay. To achieve better performance, use the Draw method on the bounding box of the Strokes collection. Note that this means converting the bounding box from ink space coordinates to pixel coordinates.
Private Sub ChangeColor(ByVal theStrokes As Strokes, ByVal newColor As Color)
' Change the color of theStrokes
Dim theStroke As Stroke
For Each theStroke In theStrokes
theStroke.DrawingAttributes.Color = newColor
Next
'Convert bounding box to pixel coordinates
Dim g As Graphics = CreateGraphics()
Dim strokesBounds As Rectangle = theStrokes.GetBoundingBox()
Dim topLeft As Point = strokesBounds.Location
Dim bottomRight As Point = New Point(strokesBounds.Right, strokesBounds.Bottom)
theInkOverlay.Renderer.InkSpaceToPixel(g, topLeft)
theInkOverlay.Renderer.InkSpaceToPixel(g, bottomRight)
g.Dispose()
strokesBounds = New Rectangle(topLeft, _
New Size(bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y))
'Redraw the strokes
theInkOverlay.Draw(strokesBounds)
End Sub
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