다음을 통해 공유


IncrementalHitTester.AddPoint(Point) 메서드

정의

PointIncrementalHitTester를 추가합니다.

public:
 void AddPoint(System::Windows::Point point);
public void AddPoint (System.Windows.Point point);
member this.AddPoint : System.Windows.Point -> unit
Public Sub AddPoint (point As Point)

매개 변수

point
Point

Point에 추가할 IncrementalHitTester입니다.

예제

다음 예제에서는 요소를 추가 하는 방법에 설명 합니다 IncrementalHitTester 사용자 마우스를 사용 하 여 데이터를 입력 하는 경우. 예제에 포함 되어는 StrokeHit 의 일부는 이벤트 처리기는 Stroke 사용자 교차 하는 합니다. 사용자가 잉크를 지울 수 있도록 하는 컨트롤을 만들려면 참조 방법: 사용자 지정 컨트롤에서 잉크 지우기합니다.

protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
    base.OnMouseLeftButtonDown(e);

    if (e.StylusDevice != null)
    {
        return;
    }

    EllipseStylusShape eraserTip = new EllipseStylusShape(3, 3, 0);
    eraseTester =
        presenter.Strokes.GetIncrementalStrokeHitTester(eraserTip);
    eraseTester.StrokeHit += new StrokeHitEventHandler(eraseTester_StrokeHit);
    eraseTester.AddPoint(e.GetPosition(this));
}

protected override void OnMouseMove(MouseEventArgs e)
{
    base.OnMouseMove(e);
    
    if (e.StylusDevice != null || eraseTester == null)
    {
        return;
    }

    if (eraseTester.IsValid)
    {
        eraseTester.AddPoint(e.GetPosition(this));
    }
}

protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
{
    base.OnMouseLeftButtonUp(e);

    if (e.StylusDevice != null)
    {
        return;
    }

    eraseTester.AddPoint(e.GetPosition(this));
    eraseTester.StrokeHit -= new
        StrokeHitEventHandler(eraseTester_StrokeHit);
    eraseTester.EndHitTesting();
}
Protected Overrides Sub OnMouseLeftButtonDown(ByVal e As MouseButtonEventArgs)

    MyBase.OnMouseLeftButtonDown(e)

    If Not e.StylusDevice Is Nothing Then
        Return
    End If

    Dim eraserTip As EllipseStylusShape = New EllipseStylusShape(3, 3, 0)
    eraseTester = _
        presenter.Strokes.GetIncrementalStrokeHitTester(eraserTip)
    AddHandler eraseTester.StrokeHit, _
        AddressOf eraseTester_StrokeHit
    eraseTester.AddPoint(e.GetPosition(Me))

End Sub

Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
    MyBase.OnMouseMove(e)

    If Not e.StylusDevice Is Nothing Or eraseTester Is Nothing Then
        Return
    End If

    If (eraseTester.IsValid) Then
        eraseTester.AddPoint(e.GetPosition(Me))
    End If
End Sub

Protected Overrides Sub OnMouseLeftButtonUp(ByVal e As MouseButtonEventArgs)
    MyBase.OnMouseLeftButtonUp(e)

    If Not e.StylusDevice Is Nothing Then
        Return
    End If

    eraseTester.AddPoint(e.GetPosition(Me))
    RemoveHandler eraseTester.StrokeHit, _
        AddressOf eraseTester_StrokeHit
    eraseTester.EndHitTesting()
End Sub
// When the stylus intersects a stroke, erase that part of
// the stroke.  When the stylus dissects a stoke, the 
// Stroke.Erase method returns a StrokeCollection that contains
// the two new strokes.
void eraseTester_StrokeHit(object sender,
    StrokeHitEventArgs args)
{
    StrokeCollection eraseResult =
        args.GetPointEraseResults();
    StrokeCollection strokesToReplace = new StrokeCollection();
    strokesToReplace.Add(args.HitStroke);
   
    // Replace the old stroke with the new one.
    if (eraseResult.Count > 0)
    {
        presenter.Strokes.Replace(strokesToReplace, eraseResult);
    }
    else
    {
        presenter.Strokes.Remove(strokesToReplace);
    }
}
' When the stylus intersects a stroke, erase that part of
' the stroke.  When the stylus dissects a stoke, the 
' Stroke.Erase method returns a StrokeCollection that contains
' the two new strokes.
Private Sub eraseTester_StrokeHit(ByVal sender As Object, _
        ByVal args As StrokeHitEventArgs)

    Dim eraseResult As StrokeCollection = _
        args.GetPointEraseResults()
    Dim strokesToReplace As New StrokeCollection()
    strokesToReplace.Add(args.HitStroke)

    ' Replace the old stroke with the new one.
    If eraseResult.Count > 0 Then
        presenter.Strokes.Replace(strokesToReplace, eraseResult)
    Else
        presenter.Strokes.Remove(strokesToReplace)
    End If

End Sub

적용 대상