Export (0) Print
Expand All

StrokeCollection.GetIncrementalLassoHitTester Method

Creates an IncrementalLassoHitTester that hit tests the StrokeCollection with a lasso (freehand) path.

Namespace:  System.Windows.Ink
Assembly:  PresentationCore (in PresentationCore.dll)

public IncrementalLassoHitTester GetIncrementalLassoHitTester(
	int percentageWithinLasso


Type: System.Int32

The minimum percentage of each Stroke that must be contained within the lasso for it to be considered hit.

The GetIncrementalLassoHitTester method returns an IncrementalLassoHitTester that considers a Stroke to be "hit" when the lasso path surrounds it. This is useful for implementing features, such as the ability to select a stroke with a lasso tool. The InkCanvas uses an IncrementalLassoHitTester to implement the lasso selection tool.

The following example demonstrates how to get an IncrementalLassoHitTester that enables a user to select strokes with a lasso tool. To create a control that enables a user to select ink, see How to: Select Ink from a Custom Control.

private void InitializeHitTester(StylusPointCollection collectedPoints)
    // Deselect any selected strokes. 
    foreach (Stroke selectedStroke in selectedStrokes)
        selectedStroke.DrawingAttributes.Color = inkDA.Color;

    if (mode == InkMode.Select)
        // Remove the previously drawn lasso, if it exists. 
        if (lassoPath != null)
            lassoPath = null;

        selectionTester =
        selectionTester.SelectionChanged += 
            new LassoSelectionChangedEventHandler(selectionTester_SelectionChanged);

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft