Advertisement
joapaspe

Gestures InkOverlay

Mar 15th, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.28 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Microsoft.Ink;
  10. namespace pruebaTablet
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         InkOverlay inkOverlay;
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.  
  19.         }
  20.  
  21.         private void Form1_Load(object sender, EventArgs e)
  22.         {
  23.             inkOverlay = new InkOverlay();
  24.             inkOverlay.Handle = this.Handle;
  25.             inkOverlay.Enabled = true;
  26.             inkOverlay.Gesture += new InkCollectorGestureEventHandler(Event_OnApplicationGesture);
  27.             inkOverlay.CollectionMode = CollectionMode.InkAndGesture;
  28.             inkOverlay.SetGestureStatus(ApplicationGesture.Left, true);
  29.             inkOverlay.SetGestureStatus(ApplicationGesture.Right, true);
  30.             inkOverlay.SetGestureStatus(ApplicationGesture.Up, true);
  31.             inkOverlay.SetGestureStatus(ApplicationGesture.Down, true);
  32.             inkOverlay.SetGestureStatus(ApplicationGesture.Check,true);
  33.            
  34.         }
  35.  
  36.  
  37.         void Event_OnApplicationGesture(object sender, InkCollectorGestureEventArgs e)
  38.         {
  39.             Gesture G = e.Gestures[0];
  40.  
  41.             // we will use the gesture if it has confidence of strong or intermediate
  42.  
  43.             if (G.Confidence == RecognitionConfidence.Intermediate ||
  44.                 G.Confidence == RecognitionConfidence.Strong)
  45.             {
  46.  
  47.                 switch (G.Id)
  48.                 {
  49.                     case ApplicationGesture.Left:
  50.                         MessageBox.Show("Left");
  51.                         break;
  52.                     case ApplicationGesture.Right:
  53.                         MessageBox.Show("Right");
  54.                         break;
  55.                     case ApplicationGesture.Up:
  56.                         MessageBox.Show("Up");
  57.                         break;
  58.                     case ApplicationGesture.Down:
  59.                         MessageBox.Show("Down");
  60.                         break;
  61.                     case ApplicationGesture.Check:
  62.                         MessageBox.Show("Check");
  63.                         break;
  64.                 }
  65.             }
  66.  
  67.         }
  68.  
  69.  
  70.  
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement