TouchDevice TouchDevice TouchDevice TouchDevice Class

정의

터치 스크린에서 손가락으로 생성된 단일 터치식 입력을 나타냅니다.Represents a single touch input produced by a finger on a touchscreen.

public ref class TouchDevice abstract : System::Windows::Input::InputDevice, System::Windows::Input::IManipulator
public abstract class TouchDevice : System.Windows.Input.InputDevice, System.Windows.Input.IManipulator
type TouchDevice = class
    inherit InputDevice
    interface IManipulator
Public MustInherit Class TouchDevice
Inherits InputDevice
Implements IManipulator
상속
구현

예제

다음 예에서는 간단한 패턴에서 만들 수는 Canvas 터치 스크린에서 두 손가락을 드래그 하 여 합니다.The following example enables you to create simple patterns on a Canvas by dragging two fingers on a touchscreen. 각 터치가 나타내는 TouchDeviceTouchEventArgs합니다.Each touch is represented by a TouchDevice in the TouchEventArgs. 패턴은 터치에 의해 제공 되는 터치 지점 사이의 선을 그려 생성 됩니다.The pattern is created by drawing a line between the touch points that are provided by the touches. 이 예제에는 Windows Touch 호환 화면이 필요 합니다.This example requires a Windows Touch-compatible screen.

다음 태그에 구성 된 사용자 인터페이스를 만들고는 Canvas 가운데에 모눈을 터치 이벤트에 대 한 이벤트 처리기를 연결 합니다.The following markup creates the user interface, which consists of a Canvas that is centered in a grid, and attaches the event handlers for the touch events.

<Window x:Class="WpfTouchEventsSample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="525" Width="525">
    <Grid>
        <Canvas x:Name="canvas1"
                Width="500" Height="500"
                Background="Black"
                TouchDown="canvas_TouchDown"
                TouchMove="canvas_TouchMove"
                TouchUp="canvas_TouchUp" />
    </Grid>
</Window>

다음 코드는 터치 이벤트를 처리합니다.The following code handles the touch events. 터치를 눌렀음을 합니다 Canvas, TouchDevice 에 캡처되는지를 Canvas입니다.When a touch is pressed on the Canvas, the TouchDevice is captured to the Canvas. 터치 리프트 된 때를 TouchDevice 해제 됩니다.When the touch is lifted, the TouchDevice is released. 터치 이동 하는 경우는 Canvas, Id 확인란이 선택 되어 있습니다.When a touch moves on the Canvas, the Id is checked. 첫 번째 터치에서 이동 하는 경우, 해당 위치에 기록 됩니다.If the move came from the first touch, its location is recorded. 두 번째 터치에서 이동 하는 경우, 두 번째 터치 위치를 줄의 첫 번째 터치 위치에서 그려집니다.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.

using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Controls;

namespace WpfTouchEventsSample
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        // Variables to track the first two touch points 
        // and the ID of the first touch point.
        private Point pt1, pt2 = new Point();
        private int firstTouchId = -1;

        public MainWindow()
        {
            InitializeComponent();
        }

        private void canvas_TouchDown(object sender, TouchEventArgs e)
        {
            Canvas _canvas = (Canvas)sender as Canvas;
            if (_canvas != null)
            {
                _canvas.Children.Clear();
                e.TouchDevice.Capture(_canvas);

                // Record the ID of the first touch point if it hasn't been recorded.
                if (firstTouchId == -1)
                    firstTouchId = e.TouchDevice.Id;
            }
        }

        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);
                }
            }
        }

        private void canvas_TouchUp(object sender, TouchEventArgs e)
        {
            Canvas _canvas = (Canvas)sender as Canvas;
            if (_canvas != null && e.TouchDevice.Captured == _canvas)
            {
                _canvas.ReleaseTouchCapture(e.TouchDevice);
            }
        }
    }
}
Class MainWindow
    ' Variables to track the first two touch points 
    ' and the ID of the first touch point.
    Private pt1, pt2 As Point
    Private firstTouchId As Integer = -1
    ' Touch Down
    Private Sub canvas_TouchDown(ByVal sender As System.Object, ByVal e As System.Windows.Input.TouchEventArgs)
        Dim _canvas As Canvas = CType(sender, Canvas)
        If (_canvas IsNot Nothing) Then
            _canvas.Children.Clear()
            e.TouchDevice.Capture(_canvas)

            ' Record the ID of the first touch point if it hasn't been recorded.
            If firstTouchId = -1 Then
                firstTouchId = e.TouchDevice.Id
            End If
        End If
    End Sub
    ' 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
    ' Touch Up
    Private Sub canvas_TouchUp(ByVal sender As System.Object, ByVal e As System.Windows.Input.TouchEventArgs)
        Dim _canvas As Canvas = CType(sender, Canvas)
        If (_canvas IsNot Nothing AndAlso e.TouchDevice.Captured Is _canvas) Then
            _canvas.ReleaseTouchCapture(e.TouchDevice)

        End If
    End Sub
End Class

설명

일반적으로 액세스 한 TouchDevice 를 사용 하 여는 TouchEventArgs.TouchDevice 속성입니다.You typically access a TouchDevice by using the TouchEventArgs.TouchDevice property. TouchDevice 화면의 단일 터치를 나타냅니다.A TouchDevice represents a single touch on a screen. 사용 하 여 여러 터치가 없는 경우는 Id 구별할 속성입니다.If multiple touches are present, use the Id property to distinguish between them.

참고

이 클래스는 모든 멤버에 적용 되는 클래스 수준에서 상속 요청을 포함 합니다.This class contains an inheritance demand at the class level that applies to all members. SecurityException 파생된 클래스에는 완전 신뢰 권한이 없는 경우 throw 됩니다.A SecurityException is thrown when the derived class does not have full-trust permission. 보안 요청에 대 한 자세한 내용은 참조 하세요. 링크 요구가 하 고 상속 요청합니다.For more information about security demands, see Link Demands and Inheritance Demands.

생성자

TouchDevice(Int32) TouchDevice(Int32) TouchDevice(Int32) TouchDevice(Int32)

TouchDevice 클래스를 초기화하기 위해 파생 클래스의 생성자에서 호출됩니다.Called from constructors in derived classes to initialize the TouchDevice class.

속성

ActiveSource ActiveSource ActiveSource ActiveSource

이 디바이스에 대한 입력을 보고하는 PresentationSource를 가져옵니다.Gets the PresentationSource that is reporting input for this device.

Captured Captured Captured Captured

TouchDevice를 캡처한 요소를 가져옵니다.Gets the element that captured the TouchDevice.

CaptureMode CaptureMode CaptureMode CaptureMode

TouchDevice의 캡처 정책을 가져옵니다.Gets the capture policy of the TouchDevice.

DirectlyOver DirectlyOver DirectlyOver DirectlyOver

터치 접촉 지점 바로 아래에 있는 요소를 가져옵니다.Gets the element that the touch contact point is directly over.

Dispatcher Dispatcher Dispatcher Dispatcher

Dispatcher와 연결된 DispatcherObject를 가져옵니다.Gets the Dispatcher this DispatcherObject is associated with.

(Inherited from DispatcherObject)
Id Id Id Id

운영 체제에서 제공한 TouchDevice의 고유 식별자를 가져옵니다.Gets the unique identifier of the TouchDevice, as provided by the operating system.

IsActive IsActive IsActive IsActive

디바이스가 활성 상태인지 여부를 나타내는 값을 가져옵니다.Gets a value that indicates whether the device is active.

Target Target Target Target

TouchDevice에서 입력을 받는 요소를 가져옵니다.Gets the element that receives input from the TouchDevice.

메서드

Activate() Activate() Activate() Activate()

입력 메시징 시스템에 TouchDevice를 추가합니다.Adds the TouchDevice to the input messaging system.

Capture(IInputElement) Capture(IInputElement) Capture(IInputElement) Capture(IInputElement)

Element 캡처 모드를 사용하여 지정된 요소에 터치를 캡처합니다.Captures a touch to the specified element by using the Element capture mode.

Capture(IInputElement, CaptureMode) Capture(IInputElement, CaptureMode) Capture(IInputElement, CaptureMode) Capture(IInputElement, CaptureMode)

지정된 CaptureMode를 사용하여 지정된 요소에 터치를 캡처합니다.Captures a touch to the specified element by using the specified CaptureMode.

CheckAccess() CheckAccess() CheckAccess() CheckAccess()

호출 스레드가 이 DispatcherObject에 액세스할 수 있는지 여부를 확인합니다.Determines whether the calling thread has access to this DispatcherObject.

(Inherited from DispatcherObject)
Deactivate() Deactivate() Deactivate() Deactivate()

입력 메시징 시스템에서 TouchDevice를 제거합니다.Removes the TouchDevice from the input messaging system.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

지정한 개체와 현재 개체가 같은지 여부를 확인합니다.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

기본 해시 함수로 작동합니다.Serves as the default hash function.

(Inherited from Object)
GetIntermediateTouchPoints(IInputElement) GetIntermediateTouchPoints(IInputElement) GetIntermediateTouchPoints(IInputElement) GetIntermediateTouchPoints(IInputElement)

파생 클래스에서 재정의된 경우 최신 터치 이벤트와 이전 터치 이벤트 사이에 수집된 모든 터치 지점을 반환합니다.When overridden in a derived class, returns all touch points that are collected between the most recent and previous touch events.

GetTouchPoint(IInputElement) GetTouchPoint(IInputElement) GetTouchPoint(IInputElement) GetTouchPoint(IInputElement)

지정된 요소를 기준으로 터치 디바이스의 현재 위치를 반환합니다.Returns the current position of the touch device relative to the specified element.

GetType() GetType() GetType() GetType()

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(Inherited from Object)
OnCapture(IInputElement, CaptureMode) OnCapture(IInputElement, CaptureMode) OnCapture(IInputElement, CaptureMode) OnCapture(IInputElement, CaptureMode)

터치가 요소에 캡처될 때 호출됩니다.Called when a touch is captured to an element.

OnManipulationEnded(Boolean) OnManipulationEnded(Boolean) OnManipulationEnded(Boolean) OnManipulationEnded(Boolean)

조작이 종료되었을 때 호출됩니다.Called when a manipulation has ended.

OnManipulationStarted() OnManipulationStarted() OnManipulationStarted() OnManipulationStarted()

조작이 시작될 때 호출됩니다.Called when a manipulation is started.

ReportDown() ReportDown() ReportDown() ReportDown()

요소에서 터치를 눌렀음을 보고합니다.Reports that a touch is pressed on an element.

ReportMove() ReportMove() ReportMove() ReportMove()

요소에서 터치가 움직이고 있음을 보고합니다.Reports that a touch is moving across an element.

ReportUp() ReportUp() ReportUp() ReportUp()

요소에서 터치를 해제했음을 보고합니다.Reports that a touch was lifted from an element.

SetActiveSource(PresentationSource) SetActiveSource(PresentationSource) SetActiveSource(PresentationSource) SetActiveSource(PresentationSource)

이 디바이스에 대한 입력을 보고하는 PresentationSource를 설정합니다.Sets the PresentationSource that is reporting input for this device.

Synchronize() Synchronize() Synchronize() Synchronize()

TouchDevice에서 사용자 인터페이스를 기본 터치 지점과 동기화하도록 강제합니다.Forces the TouchDevice to synchronize the user interface with underlying touch points.

ToString() ToString() ToString() ToString()

현재 개체를 나타내는 문자열을 반환합니다.Returns a string that represents the current object.

(Inherited from Object)
VerifyAccess() VerifyAccess() VerifyAccess() VerifyAccess()

호출 스레드에서 이 DispatcherObject에 액세스할 수 있는지 확인합니다.Enforces that the calling thread has access to this DispatcherObject.

(Inherited from DispatcherObject)

이벤트

Activated Activated Activated Activated

TouchDevice가 입력 메시징 시스템에 추가되면 발생합니다.Occurs when the TouchDevice is added to the input messaging system.

Deactivated Deactivated Deactivated Deactivated

TouchDevice가 입력 메시징 시스템에서 제거될 때 발생합니다.Occurs when the TouchDevice is removed from the input messaging system.

Updated Updated Updated Updated

터치 메시지가 전송되면 발생합니다.Occurs when a touch message is sent.

명시적 인터페이스 구현

IManipulator.GetPosition(IInputElement) IManipulator.GetPosition(IInputElement) IManipulator.GetPosition(IInputElement) IManipulator.GetPosition(IInputElement)

IManipulator 개체의 위치를 반환합니다.Returns the position of the IManipulator object.

IManipulator.Id IManipulator.Id IManipulator.Id IManipulator.Id

운영 체제에서 제공한 TouchDevice의 고유 식별자를 가져옵니다.Gets the unique identifier of the TouchDevice as provided by the operating system.

IManipulator.ManipulationEnded(Boolean) IManipulator.ManipulationEnded(Boolean) IManipulator.ManipulationEnded(Boolean) IManipulator.ManipulationEnded(Boolean)

조작이 종료되면 발생합니다.Occurs when a manipulation has ended.

보안

UIPermission
이 클래스에서 파생 됩니다.for deriving from this class. 보안 동작: InheritanceDemand합니다.Security action: InheritanceDemand. 연결 된 열거형: UnrestrictedAssociated enumeration: Unrestricted

적용 대상