The following steps indicate how to detect gestures, rotation, and scale and transition.
1. Add a Label control to the Form(Label1) and set the following properties:
· AutoSize = False
· BackColor = Color.Cyan
· Size = Size(300, 300)
2. Add a C1TouchEventProvider to the Form. (C1TouchEventProvider1)
3. Select Label1 and set the "EnableTouchEvents of C1TouchEventProvider1" property to True in the Property Window.
4. Select the C1TouchEventProvider1, and add the following code to its ManipulationDelta event.
[C#]
using C1.Win.TouchToolKit;
private void Form1_Load(object sender, System.EventArgs e) { label1.AutoSize = false; label1.BackColor = Color.Cyan; label1.Size = new Size(300, 300); c1TouchEventProvider1.SetEnableTouchEvents(label1, true); c1TouchEventProvider1.ManipulationDelta += c1TouchEventProvider1_ManipulationDelta; }
private void c1TouchEventProvider1_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) { if (e.TargetControl == this.label1) { label1.Text = string.Format("Scale:{0}\r\nRotation:{1}\r\nTranslation:{2}", e.Delta.Scale, e.Delta.Rotation, e.Delta.Translation); } } |
[Visual Basic]
Imports C1.Win.TouchToolKit
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Label1.AutoSize = False Label1.BackColor = Color.Cyan Label1.Size = New Size(300, 300) C1TouchEventProvider1.SetEnableTouchEvents(Label1, True) End Sub
Private Sub C1TouchEventProvider1_ManipulationDelta(sender As System.Object, e As ManipulationDeltaEventArgs) Handles C1TouchEventProvider1.ManipulationDelta If e.TargetControl Is Label1 Then Label1.Text = String.Format("Scale:{0}\r\nRotation:{1}\r\nTranslation:{2}", e.Delta.Scale, e.Delta.Rotation, e.Delta.Translation) End If End Sub |
5. Run the project, and operate Rotation or Scale multi-touch actions on the Label1.
You can use C1TouchEventProvider.ManipulationMode property to detect specific gestures. To detect only rotation gesture, use the following code.
[C#]
c1TouchEventProvider1.ManipulationMode = C1.Win.TouchToolKit.ManipulationModes.Rotate; |
[Visual Basic]
C1TouchEventProvider1.ManipulationMode = C1.Win.TouchToolKit.ManipulationModes.Rotate |
To detect multiple gesture, use the following code.
[C#]
using C1.Win.TouchToolKit;
c1TouchEventProvider1.ManipulationMode = ManipulationModes.Rotate | ManipulationModes.Scale; |
[Visual Basic]
Imports C1.Win.TouchToolKit
C1TouchEventProvider1.ManipulationMode = ManipulationModes.Rotate Or ManipulationModes.Scale |