Ink.Clip Method

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

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

Syntax

'Declaration
Public Sub Clip ( _
    r As Rectangle _
)
'Usage
Dim instance As Ink 
Dim r As Rectangle

instance.Clip(r)
public void Clip(
    Rectangle r
)
public:
void Clip(
    Rectangle r
)
public function Clip(
    r : Rectangle
)

Parameters

Remarks

The r paramter is specified in ink space coordinates.

Portions of the ink outside of the rectangle are deleted from the Ink object. Because of this, the Clip method may add new points to a Stroke object at the point where the Stroke object intersects the rectangle.

After you call the Clip method on an Ink object, the properties of each Stroke object in the Ink object's Strokes collection 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.

This method does not take the pen width into account when clipping. It clips only the actual ink or stroke data.

For a Stroke object or Strokes collection, the Clip 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.

For more information about how ink data is manipulated, see Ink Data.

Examples

In this example, the client area of the ink control is obtained, converted to HIMETRIC units, and then reduced in size by 1500 units. The Clip method is then used to remove the portions of Stroke objects that fall outside the rectangle.

' get the bottom right point of the client area for ink 
' Note: InkOverlay.AttachedControl property must be set 
Dim bottomRight As Point = New Point(mInkOverlay.AttachedControl.ClientSize)
' convert to HIMETRIC units 
Using g As Graphics = mInkOverlay.AttachedControl.CreateGraphics()
    mInkOverlay.Renderer.PixelToInkSpace(g, bottomRight)
End Using 
' create a rectangle of the client area (HIMETRIC units) 
Dim R As Rectangle = New Rectangle(0, 0, bottomRight.X, bottomRight.Y)
' shrink the rectangle by 1500 
R.Inflate(-1500, -1500)
' clip the strokes to the rectangle
mInkOverlay.Ink.Clip(R)
mInkOverlay.AttachedControl.Invalidate()
// get the bottom right point of the client area for ink 
// Note: InkOverlay.AttachedControl property must be set
Point bottomRight = new Point(mInkOverlay.AttachedControl.ClientSize);
// convert to HIMETRIC units 
using (Graphics g = mInkOverlay.AttachedControl.CreateGraphics())
{
    mInkOverlay.Renderer.PixelToInkSpace(g, ref bottomRight);
}
// create a rectangle of the client area (HIMETRIC units)
Rectangle R = new Rectangle(0, 0, bottomRight.X, bottomRight.Y);
// shrink the rectangle by 1500 
R.Inflate(-1500, -1500);
// clip the strokes to the rectangle
mInkOverlay.Ink.Clip(R);
mInkOverlay.AttachedControl.Invalidate();

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

Microsoft.Ink Namespace

Ink.HitTest

Stroke

Strokes