Share via


Ink.ClipboardCopy Method (Rectangle, InkClipboardFormats, InkClipboardModes)

Copies the Strokes collection contained in the specified rectangle to the Clipboard.

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink (in Microsoft.Ink.dll)

Syntax

'Declaration
Public Function ClipboardCopy ( _
    copyRectangle As Rectangle, _
    formats As InkClipboardFormats, _
    modes As InkClipboardModes _
) As IDataObject
'Usage
Dim instance As Ink 
Dim copyRectangle As Rectangle 
Dim formats As InkClipboardFormats 
Dim modes As InkClipboardModes 
Dim returnValue As IDataObject 

returnValue = instance.ClipboardCopy(copyRectangle, _
    formats, modes)
public IDataObject ClipboardCopy(
    Rectangle copyRectangle,
    InkClipboardFormats formats,
    InkClipboardModes modes
)
public:
IDataObject^ ClipboardCopy(
    Rectangle copyRectangle, 
    InkClipboardFormats formats, 
    InkClipboardModes modes
)
public function ClipboardCopy(
    copyRectangle : Rectangle, 
    formats : InkClipboardFormats, 
    modes : InkClipboardModes
) : IDataObject

Parameters

Return Value

Type: System.Windows.Forms.IDataObject
Returns the data object to be created. The default value is nulla null reference (Nothing in Visual Basic) (Nothing in Microsoft Visual Basic.NET).

Remarks

If the rectangle clips Stroke objects, the corresponding Stroke objects are clipped in the copied data.

It may be useful to copy an entire Ink object to the Clipboard when you want to copy all of the properties of the Ink object. To copy an Ink object to the Clipboard, call the ClipboardCopy(Strokes, InkClipboardFormats, InkClipboardModes) method with the strokes parameter set to null (Nothing in Visual Basic .NET).

When you use the ClipboardCopy(Rectangle, InkClipboardFormats, InkClipboardModes) method in InkClipboardModes mode, a Stroke object that gets split into two or more strokes is deleted and new strokes are added in its place.

Ink.InkDeleted events are generated based on the indices of the Stroke objects within the Strokes collection. For example, if the Stroke objects at indices 0, 1, 2, 3, 5, and 6 are to be deleted, two events are generated. One event is generated for Stroke objects with indices 0, 1, 2, and 3; and one event is generated for Stroke objects with indices 5 and 6. That is, there is one event for each contiguous set. This also applies to InkAdded events; however, an internal algorithm determines the indices of the newly added Stroke objects in the Strokes collection and has an impact on how the InkAdded events are fired.

If you query for the Strokes collection's Count property from within the event handler, the result is the total number of Stroke objects added by the whole operation, including the Stroke objects that have not yet generated events.

Warning

To avoid potential memory leaks as a result of using the InkClipboardModes flag, call the System.Windows.Forms.Clipboard.SetDataObject(System.Object) method of the Clipboard object. This must be done before the application exits if the last call to the ClipboardCopy method used the DelayedCopy flag in enumeration InkClipboardModes..

Security noteSecurity Note:

If using under partial trust, this method requires UIPermissionClipboard.OwnClipboard permission. See Security And Trust for more information.

Examples

This C# example copies all of the ink from the Rectangle structure, theRectangle, into the InkCollector object, theInkCollector to the Clipboard.

try
{
    theInkCollector.Ink.ClipboardCopy(theRectangle,
        InkClipboardFormats.Default, InkClipboardModes.Copy);
}
catch
{
    // Place exception handling code here.
}

This Visual Basic .NET example copies all of the ink from the Rectangle structure, theRectangle, into the InkCollector object, theInkCollector to the Clipboard.

Try
    theInkCollector.Ink.ClipboardCopy(theRectangle,
        InkClipboardFormats.Default, InkClipboardModes.Copy)
Catch
    'Place exception handling code here.
End Try

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

See Also

Reference

Ink Class

Ink Members

ClipboardCopy Overload

Microsoft.Ink Namespace

ClipboardPaste