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 void AddStrokesAtRectangle (
Strokes strokes,
Rectangle destinationRectangle
)
public function AddStrokesAtRectangle (
strokes : Strokes,
destinationRectangle : Rectangle
)
Not applicable.
Parameters
- destinationRectangle
The 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.
Example
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 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.
Version Information
.NET Framework
Supported in: 3.0