Condividi tramite


Strokes.Clip Method

Strokes.Clip Method

Removes the portions of every Stroke object in the Strokes collection that are outside a given rectangle.

Definition

Visual Basic .NET Public Sub Clip( _
ByVal r As Rectangle _
)
C# public void Clip(
Rectangle r
);
Managed C++ public: void Clip(
Rectangle *r
);

Parameters

r System.Drawing.Rectangle. The rectangle outside of which each Stroke object in the collection is clipped.

Exceptions

ObjectDisposedException Leave Site: The Strokes collection is disposed.

Remarks

The r parameter is specified in ink space coordinates.

This method updates the parent Ink object. Whenever ink is removed from an Ink object, any Stroke objects or Strokes collections defined for that Ink object may be invalidated.

After you call the Clip method , the properties of each Stroke object may change. For example, if a Stroke object begins within the area of the clip rectangle, exits the clip rectangle, and then returns to within the clip rectangle; it becomes two Stroke objects, at least one of which has a new Id property. Despite this behavior, all Id properties are guaranteed to be unique within an Ink object, even if they change. Other properties for the Stroke object may also undergo similar change.

Examples

[C#]

This C# example calls the GetBoundingBox method to determine the bounding rectangle for a Strokes collection of an InkOverlay, theInkOverlay. It then calls the Clip method to clip the right half of the Strokes collection in theInkOverlay.

//Determine the bounding box for the Strokes collection.
Rectangle inkBounds = theInkOverlay.Ink.Strokes.GetBoundingBox();
//Create rectangle for Clip method.
Rectangle halfRectangle = new Rectangle(inkBounds.Left,
    inkBounds.Top, inkBounds.Width / 2, inkBounds.Height);
//Clip the Strokes collection.
theInkOverlay.Ink.Strokes.Clip(halfRectangle);
                

[VB.NET]

This Microsoft® Visual Basic® .NET example calls the GetBoundingBox method to determine the bounding rectangle for a Strokes collection of an InkOverlay, theInkOverlay. It then calls the Clip method to clip the right half of the Strokes collection in theInkOverlay.

'Determine the bounding box for the Strokes collection.
Dim inkBounds As Rectangle = theInkOverlay.Ink.Strokes.GetBoundingBox()
'Create rectangle for Clip method.
Dim halfRectangle As New Rectangle(inkBounds.Left, _
    inkBounds.Top, inkBounds.Width / 2, inkBounds.Height)
'Clip the Strokes collection.
theInkOverlay.Ink.Strokes.Clip(halfRectangle)
                

See Also