StrokeCollection.GetIncrementalLassoHitTester(Int32) 方法

定义

创建一个通过套索(手工绘制)路径对 IncrementalLassoHitTester 进行命中测试的 StrokeCollection

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

参数

percentageWithinLasso
Int32

每一 Stroke 必须包含在套索内的最低百分比,达到此百分比时将视为被命中。

返回

IncrementalLassoHitTester 进行命中测试的 StrokeCollection

示例

以下示例演示如何获取 IncrementalLassoHitTester ,使用户能够使用套索工具选择笔划。 若要创建允许用户选择墨迹的控件,请参阅 如何:从自定义控件中选择墨迹

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

注解

方法 GetIncrementalLassoHitTester 返回一个 , IncrementalLassoHitTester 当套索路径环绕该套索时,该方法会将 视为 Stroke “命中”。 这对于实现功能非常有用,例如使用套索工具选择笔划的功能。 InkCanvas使用 IncrementalLassoHitTester 实现套索选择工具。

适用于