TouchDevice.Id TouchDevice.Id TouchDevice.Id TouchDevice.Id Property

定義

オペレーティング システムに用意されている、TouchDevice の一意の識別子を取得します。Gets the unique identifier of the TouchDevice, as provided by the operating system.

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

プロパティ値

TouchDevice の一意の識別子。The unique identifier of the TouchDevice.

実装

Id

次の例のハンドル、TouchMoveで発生するイベント、Canvasします。The following example handles the TouchMove events that occur on a Canvas. タッチが移動したときに、 CanvasIdがチェックされます。When a touch moves on the Canvas, the Id is checked. 最初のタッチの場合は、その場所が記録されます。If the move came from the first touch, its location is recorded. 2 つ目のタッチの場合は、行は最初のタッチの位置から 2 番目のタッチの位置に描画されます。If the move came from the second touch, a line is drawn from the position of the first touch to the position of the second touch.

この例は例で使用できる、TouchDeviceクラスの概要。This example is part of a larger example available in the TouchDevice class overview.

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

注釈

ATouchDevice画面上の 1 つのタッチを表します。A TouchDevice represents a single touch on a screen. 複数のタッチが存在する場合を使用して、Idプロパティを区別します。If multiple touches are present, use the Id property to distinguish between them.

適用対象