Поделиться через


Ink.AddStrokesAtRectangle - метод

Обновлен: Ноябрь 2007

Specifies the known Strokes collection to insert into this Ink object at a specified rectangle.

Пространство имен:  Microsoft.Ink
Сборка:  Microsoft.Ink (в Microsoft.Ink.dll)

Синтаксис

'Декларация
Public Sub AddStrokesAtRectangle ( _
    strokes As Strokes, _
    destinationRectangle As Rectangle _
)
'Применение
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
)

Параметры

  • destinationRectangle
    Тип: System.Drawing.Rectangle
    The rectangle where the strokes are added, in ink space coordinates.

Заметки

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.

Примеры

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

Платформы

Windows Vista

Среды .NET Framework и .NET Compact Framework поддерживают не все версии каждой платформы. Поддерживаемые версии перечислены в разделе Требования к системе для .NET Framework.

Сведения о версии

.NET Framework

Поддерживается в версии: 3.0

См. также

Ссылки

Ink Класс

Ink - члены

Microsoft.Ink - пространство имен

Strokes