Share via


Stroke.Split Method

Splits the Stroke object at the specified location on the Stroke object and returns the new Stroke object.

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

Syntax

'Declaration
Public Function Split ( _
    findex As Single _
) As Stroke
'Usage
Dim instance As Stroke 
Dim findex As Single 
Dim returnValue As Stroke 

returnValue = instance.Split(findex)
public Stroke Split(
    float findex
)
public:
Stroke^ Split(
    float findex
)
public function Split(
    findex : float
) : Stroke

Parameters

  • findex
    Type: System.Single

    The floating point index value that represents where to split the Stroke object.

Return Value

Type: Microsoft.Ink.Stroke
The new Stroke object that is created as a result of calling this method.

Remarks

A floating point index is a float value that represents a location somewhere between two points in the stroke. As examples, if 0.0 is the first point in the stroke and 1.0 is the second point in the stroke, 0.5 is halfway between the first and second points. Similarly, a floating point index value of 37.25 represents a location that is 25 percent along the line between points 37 and 38 of the stroke.

When a Stroke is split, one portion of the stroke retains the Id property of the original Stroke object. The other portion of the Stroke becomes a new Stroke object with an Id property that is one greater than the highest existing Id property. If the original Stroke was in a Strokes collection (other than the Ink.Strokes), only the beginning portion remains in that collection.

Examples

In this example, each selected Stroke object of an InkOverlay is examined. If the Stroke has at least one intersection with the rest of the Strokes collection in the Ink object, the Stroke is split at the first point of intersection.

' Access to the Strokes property returns a copy of the Strokes object. 
' This copy must be implicitly (via using statement) or explicitly 
' disposed of in order to avoid a memory leak. 
Using allStrokes As Strokes = mInkOverlay.Ink.Strokes
    For Each S As Stroke In mInkOverlay.Selection
        ' find the intersections 
        Dim intersections() As Single = S.FindIntersections(allStrokes)
        ' if we have at least 1 intersection, split the stroke 
        If intersections.Length > 0 Then
            S.Split(intersections(0))
        End If 
    Next 
End Using
// Access to the Strokes property returns a copy of the Strokes object. 
// This copy must be implicitly (via using statement) or explicitly 
// disposed of in order to avoid a memory leak. 
using (Strokes allStrokes = mInkOverlay.Ink.Strokes)
{
    foreach (Stroke S in mInkOverlay.Selection)
    {
        // find the intersections 
        float[] intersections = S.FindIntersections(allStrokes);
        // if we have at least 1 intersection, split the stroke 
        if (intersections.Length > 0)
        {
            S.Split(intersections[0]);
        }
    }
}

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

Stroke Class

Stroke Members

Microsoft.Ink Namespace