TouchToolKit for WinForms | ComponentOne
Touch Event Provider / Routing Policy / Routed Event Information
In This Topic
    Routed Event Information
    In This Topic

    All event args of C1TouchEventProvider are inherited from the TouchRoutedEventArgs class. You can get the TargetControl and OriginalSource from the TouchRoutedEventArgs. The TargetControl is the control for current event. The OriginalSource is the first control which received this event.

    For example, Button1 is a child of Panel1. Both Button1 and Panel1 are attached to the C1TouchEventProvider. When Button1 receives the TouchEvent, the TargetControl is "Button1" and the OriginalSource is "Button1". When Panel1 receives the TouchEvent, TargetControl is "Panel1" and OriginalSource is "Button1".

     

    [C#]

    using C1.Win.TouchToolKit;

     

    private void Form1_Load(object sender, EventArgs e)

    {

        this.c1TouchEventProvider1.SetEnableTouchEvents(button1, true);

        this.c1TouchEventProvider1.SetEnableTouchEvents(panel1, true);

        this.c1TouchEventProvider1.Tapped += new EventHandler<TappedEventArgs>(c1TouchEventProvider1_Tapped);

    }

     

    private void c1TouchEventProvider1_Tapped(object sender, TappedEventArgs e)

    {

        if (e.TargetControl != null)

            Console.WriteLine("{0},{1},{2}", DateTime.Now.ToString(), e.TargetControl.Name, e.OriginalSource.Name);

    }

     

    [Visual Basic]

    Imports C1.Win.TouchToolKit

     

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        C1TouchEventProvider1.SetEnableTouchEvents(Button1, True)

        C1TouchEventProvider1.SetEnableTouchEvents(Panel1, True)

    End Sub

     

    Private Sub C1TouchEventProvider1_Tapped(sender As System.Object, e As TappedEventArgs) Handles C1TouchEventProvider1.Tapped

        If Not e.TargetControl Is Nothing Then

            Console.WriteLine("{0},{1},{2}", DateTime.Now.ToString(), e.TargetControl.Name, e.OriginalSource.Name)

        End If

    End Sub