StrokeCollection.GetIncrementalLassoHitTester(Int32) StrokeCollection.GetIncrementalLassoHitTester(Int32) StrokeCollection.GetIncrementalLassoHitTester(Int32) StrokeCollection.GetIncrementalLassoHitTester(Int32) Method

Definition

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

public:
 System::Windows::Ink::IncrementalLassoHitTester ^ GetIncrementalLassoHitTester(int percentageWithinLasso);
public System.Windows.Ink.IncrementalLassoHitTester GetIncrementalLassoHitTester (int percentageWithinLasso);
member this.GetIncrementalLassoHitTester : int -> System.Windows.Ink.IncrementalLassoHitTester
Public Function GetIncrementalLassoHitTester (percentageWithinLasso As Integer) As IncrementalLassoHitTester

Parameters

percentageWithinLasso
Int32 Int32 Int32 Int32

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

Returns

Examples

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);
    }
}
Private Sub InitializeHitTester(ByVal collectedPoints As StylusPointCollection)
    ' Deselect any selected strokes.
    Dim selectedStroke As Stroke
    For Each selectedStroke In selectedStrokes
        selectedStroke.DrawingAttributes.Color = inkDA.Color
    Next selectedStroke
    selectedStrokes.Clear()


    If mode = InkMode.SelectMode Then

        ' Remove the previously drawn lasso, if it exists.
        If Not (lassoPath Is Nothing) Then
            presenter.Strokes.Remove(lassoPath)
            lassoPath = Nothing
        End If

        selectionTester = presenter.Strokes.GetIncrementalLassoHitTester(80)
        AddHandler selectionTester.SelectionChanged, AddressOf selectionTester_SelectionChanged
        selectionTester.AddPoints(collectedPoints)
    End If

End Sub 'InitializeHitTester

Remarks

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.

Applies to