StrokeCollection.GetIncrementalLassoHitTester(Int32) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
The minimum percentage of each Stroke that must be contained within the lasso for it to be considered hit.
Returns
An IncrementalLassoHitTester that hit tests the StrokeCollection.
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
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
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기