TouchDevice.Id 속성

정의

운영 체제에서 제공한 TouchDevice의 고유 식별자를 가져옵니다.

public:
 property int Id { int get(); };
public int Id { get; }
member this.Id : int
Public ReadOnly Property Id As Integer

속성 값

TouchDevice의 고유 식별자입니다.

예제

다음 예제에서는 처리 합니다 TouchMove 에서 일어나는 이벤트를 Canvas입니다. 터치가 에서 Canvas이동하면 가 Id 선택됩니다. 첫 번째 터치에서 이동 하는 경우, 해당 위치에 기록 됩니다. 두 번째 터치에서 이동 하는 경우, 두 번째 터치 위치를 줄의 첫 번째 터치 위치에서 그려집니다.

이 예제는에서 사용할 수 있는 보다 큰 예제의 일부는 TouchDevice 클래스 개요입니다.

private void canvas_TouchMove(object sender, TouchEventArgs e)
{
    Canvas _canvas = (Canvas)sender as Canvas;
    if (_canvas != null)
    {
        TouchPoint tp = e.GetTouchPoint(_canvas);
        // This is the first touch point; just record its position.
        if (e.TouchDevice.Id == firstTouchId)
        {
            pt1.X = tp.Position.X;
            pt1.Y = tp.Position.Y;
        }
        // This is not the first touch point; draw a line from the first point to this one.
        else if (e.TouchDevice.Id != firstTouchId)
        {
            pt2.X = tp.Position.X;
            pt2.Y = tp.Position.Y;

            Line _line = new Line();
            _line.Stroke = new RadialGradientBrush(Colors.White, Colors.Black);
            _line.X1 = pt1.X;
            _line.X2 = pt2.X;
            _line.Y1 = pt1.Y;
            _line.Y2 = pt2.Y;

            _line.StrokeThickness = 2;
            _canvas.Children.Add(_line);
        }
    }
}
' Touch Move
Private Sub canvas_TouchMove(ByVal sender As System.Object, ByVal e As System.Windows.Input.TouchEventArgs)
    Dim _canvas As Canvas = CType(sender, Canvas)
    If (_canvas IsNot Nothing) Then
        Dim tp = e.GetTouchPoint(_canvas)
        ' This is the first touch point; just record its position.
        If e.TouchDevice.Id = firstTouchId Then
            pt1.X = tp.Position.X
            pt1.Y = tp.Position.Y

            ' This is not the first touch point; draw a line from the first point to this one.
        ElseIf e.TouchDevice.Id <> firstTouchId Then
            pt2.X = tp.Position.X
            pt2.Y = tp.Position.Y

            Dim _line As New Line()
            _line.Stroke = New RadialGradientBrush(Colors.White, Colors.Black)
            _line.X1 = pt1.X
            _line.X2 = pt2.X
            _line.Y1 = pt1.Y
            _line.Y2 = pt2.Y

            _line.StrokeThickness = 2
            _canvas.Children.Add(_line)
        End If
    End If
End Sub

설명

TouchDevice 화면의 단일 터치를 나타냅니다. 여러 터치가 있는 경우 속성을 사용하여 Id 구분합니다.

적용 대상