StrokeCollection.GetIncrementalLassoHitTester Method (Int32)

 

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
)

Parameters

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;
    }
    selectedStrokes.Clear();


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

        selectionTester =
            presenter.Strokes.GetIncrementalLassoHitTester(80);
        selectionTester.SelectionChanged += 
            new LassoSelectionChangedEventHandler(selectionTester_SelectionChanged);
        selectionTester.AddPoints(collectedPoints);
    }
}

.NET Framework
Available since 3.0
Return to top
Show: