Ink.AddStrokesAtRectangle Method
Specifies the known Strokes collection to insert into this Ink object at a specified rectangle.
Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in Microsoft.Ink.dll)
Syntax
'Declaration
Public Sub AddStrokesAtRectangle ( _
strokes As Strokes, _
destinationRectangle As Rectangle _
)
'Usage
Dim instance As Ink
Dim strokes As Strokes
Dim destinationRectangle As Rectangle
instance.AddStrokesAtRectangle(strokes, _
destinationRectangle)
public void AddStrokesAtRectangle(
Strokes strokes,
Rectangle destinationRectangle
)
public:
void AddStrokesAtRectangle(
Strokes^ strokes,
Rectangle destinationRectangle
)
public function AddStrokesAtRectangle(
strokes : Strokes,
destinationRectangle : Rectangle
)
Parameters
strokes
Type: Microsoft.Ink.Strokes
destinationRectangle
Type: System.Drawing.RectangleThe rectangle where the strokes are added, in ink space coordinates.
Remarks
A run-time error is thrown if the coordinates of the rectangle are {0,0,0,0}.
The source Strokes collection is appended to the Ink object.
When inserted, the strokes are scaled from the bounding box of the Strokes collection to the rectangle.
This method can be used to copy strokes within a single Ink object. The source strokes need not come from another Ink object.
Examples
This C# example uses the AddStrokesAtRectangle method to take a copy of the ink from a main InkCollector object, panelMain, to a InkCollector object, panelThumb, while maintaining the proper scale and aspect ratio. To keep the thumbnail panel current, a Stroke event handler, panelMain_Stroke, is added to panelMain.
private void panelMain_Stroke(object sender, Microsoft.Ink.InkCollectorStrokeEventArgs e)
{
// Create a bounding rectangle for panelThumb in ink space coordinates
Point thePoint = Point.Empty;
using (Graphics g = Graphics.FromHwnd(Handle))
{
thePoint = new Point(panelThumb.Width, panelThumb.Height);
panelMain.Renderer.PixelToInkSpace(g, ref thePoint);
}
Rectangle theRectangle = new Rectangle(0, 0, thePoint.X, thePoint.Y);
// Delete the old strokes in the thumbnail, and add the new strokes.
panelThumb.Ink.DeleteStrokes();
// The strokes are automatically scaled to the destination rectangle
panelThumb.Ink.AddStrokesAtRectangle(panelMain.Ink.Strokes, theRectangle);
Refresh();
}
This Microsoft Visual Basic.NET example uses the AddStrokesAtRectangle method to take a copy of the ink from a main InkCollector object, panelMain, to a InkCollector object, panelThumb, while maintaining the proper scale and aspect ratio. To keep the thumbnail panel current, a Stroke event handler, panelMain_Stroke, is added to panelMain.
Private Sub panelMain_Stroke(ByVal sender As System.Object, _
ByVal e As Microsoft.Ink.InkCollectorStrokeEventArgs) Handles panelMain.Stroke
'Create a bounding rectangle for panelThumb in ink space coordinates
Dim g As Graphics = Graphics.FromHwnd(Handle)
Dim thePoint As Point = New Point(panelThumb.Width, panelThumb.Height)
panelMain.Renderer.PixelToInkSpace(g, thePoint)
'Dispose of the Graphics object
g.Dispose()
Dim theRectangle As Rectangle = New Rectangle(0, 0, thePoint.X, thePoint.Y)
'Delete the old strokes in the thumbnail, and add the new strokes.
panelThumb.Ink.DeleteStrokes()
'The strokes are automatically scaled to the destination rectangle
panelThumb.Ink.AddStrokesAtRectangle(panelMain.Ink.Strokes, theRectangle)
Refresh()
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