StrokeCollection.GetIncrementalLassoHitTester(Int32) Metoda

Definicja

Tworzy obiekt, który osiąga trafienie IncrementalLassoHitTester , testuje StrokeCollection ścieżkę lasso (freehand).

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

Parametry

percentageWithinLasso
Int32

Minimalny procent każdego Stroke z nich, który musi być zawarty w lasso, aby można było go uznać za trafiony.

Zwraca

Element IncrementalLassoHitTester , który trafi, testuje element StrokeCollection.

Przykłady

W poniższym przykładzie pokazano, jak uzyskać element IncrementalLassoHitTester , który umożliwia użytkownikowi wybranie pociągnięć za pomocą narzędzia lasso. Aby utworzyć kontrolkę, która umożliwia użytkownikowi wybieranie pisma odwłokowego, zobacz Instrukcje: wybieranie pisma odwłocznego z kontrolki niestandardowej.

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

Uwagi

Metoda GetIncrementalLassoHitTester zwraca wartość IncrementalLassoHitTester , która uważa element za Stroke "trafiony", gdy ścieżka lasso ją otacza. Jest to przydatne w przypadku implementowania funkcji, takich jak możliwość wybierania pociągnięcia za pomocą narzędzia lasso. Metoda InkCanvas używa IncrementalLassoHitTester elementu do implementowania narzędzia wyboru lasso.

Dotyczy