Lire en anglais

Partager via


TouchFrameEventArgs Classe

Définition

Fournit des données pour l'événement FrameReported.

C#
public sealed class TouchFrameEventArgs : EventArgs
Héritage
TouchFrameEventArgs

Exemples

L’exemple suivant gère l’événement FrameReported et accède aux données tactiles dans le TouchFrameEventArgs. Lorsqu’une pression tactile est enfoncée sur , Canvasle TouchDevice est capturé dans .Canvas Lorsque la pression tactile est levée, le TouchDevice est relâché. Lorsqu’une pression tactile se déplace sur le Canvas, est Id coché. Si le déplacement provient de la première touche, son emplacement est enregistré. Si le mouvement provient de la deuxième touche, une ligne est dessinée de la position de la première touche à la position de la deuxième touche.

Cet exemple fait partie d’un exemple plus large disponible dans la vue d’ensemble de la Touch classe.

C#
public partial class MainWindow : Window
{
    // Variables for tracking the position of two points.
    Point pt1, pt2 = new Point();
    
    public MainWindow()
    {
        InitializeComponent();
        Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported);
    }

    void Touch_FrameReported(object sender, TouchFrameEventArgs e)
    {
        if (this.canvas1 != null)
        {
            foreach (TouchPoint _touchPoint in e.GetTouchPoints(this.canvas1))
            {
                if (_touchPoint.Action == TouchAction.Down)
                {
                    // Clear the canvas and capture the touch to it.
                    this.canvas1.Children.Clear();
                    _touchPoint.TouchDevice.Capture(this.canvas1);
                }

                else if (_touchPoint.Action == TouchAction.Move && e.GetPrimaryTouchPoint(this.canvas1) != null)
                {   
                    // This is the first (primary) touch point. Just record its position.
                    if (_touchPoint.TouchDevice.Id == e.GetPrimaryTouchPoint(this.canvas1).TouchDevice.Id)
                    {
                        pt1.X = _touchPoint.Position.X;
                        pt1.Y = _touchPoint.Position.Y;
                    }

                    // This is not the first touch point. Draw a line from the first point to this one.
                    else if (_touchPoint.TouchDevice.Id != e.GetPrimaryTouchPoint(this.canvas1).TouchDevice.Id)
                    {
                        pt2.X = _touchPoint.Position.X;
                        pt2.Y = _touchPoint.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;
                        this.canvas1.Children.Add(_line);
                    }
                }

                else if (_touchPoint.Action == TouchAction.Up)
                {
                    // If this touch is captured to the canvas, release it.
                    if (_touchPoint.TouchDevice.Captured == this.canvas1)
                    {
                        this.canvas1.ReleaseTouchCapture(_touchPoint.TouchDevice);
                    }
                }
            }                        
        }
    }
}

Remarques

L’événement FrameReported est inclus dans Windows Presentation Foundation (WPF) pour prendre en charge la compatibilité avec Silverlight. Si vous n’avez pas besoin de garantir la compatibilité avec Silverlight, utilisez les événements tactiles, tels que TouchDown et TouchMove, sur UIElement, UIElement3Dou ContentElement.

Utilisez pour TouchFrameEventArgs obtenir les TouchPoint valeurs pertinentes pour l’événement tactile. À partir de , TouchPointvous pouvez obtenir le Position de l’interaction tactile et déterminer s’il TouchAction s’agissait d’une Downaction , Moveou Up . Vous pouvez également utiliser pour TouchPoint obtenir le TouchDevice. À partir de , TouchDevicevous pouvez déterminer l’appareil Id et obtenir des informations sur l’élément touché.

Propriétés

Timestamp

Obtient l'horodatage pour cet événement.

Méthodes

Equals(Object)

Détermine si l'objet spécifié est égal à l'objet actuel.

(Hérité de Object)
GetHashCode()

Fait office de fonction de hachage par défaut.

(Hérité de Object)
GetPrimaryTouchPoint(IInputElement)

Retourne le point tactile actuel du périphérique tactile principal par rapport à l'élément spécifié.

GetTouchPoints(IInputElement)

Retourne une collection qui contient le point tactile actuel de chaque périphérique tactile actif par rapport à l'élément spécifié.

GetType()

Obtient le Type de l'instance actuelle.

(Hérité de Object)
MemberwiseClone()

Crée une copie superficielle du Object actuel.

(Hérité de Object)
SuspendMousePromotionUntilTouchUp()

Ce membre n'est pas implémenté.

ToString()

Retourne une chaîne qui représente l'objet actuel.

(Hérité de Object)

S’applique à

Produit Versions
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10