HP Dx9000 Resources for Developing Touch-Friendly Applications for HP Business - Page 10

Application Gestures

Page 10 highlights

Application Gestures In addition to gestures and flick gestures, Windows Vista also supports application gestures. You can use Microsoft Gesture Recognizer, or create your custom gesture recognizer or use a combination of both. Microsoft Gesture Recognizer can recognize over forty gestures. The following table lists a few examples of gestures recognized by Microsoft Gesture Recognizer. Gesture Gesture name Scratch-out Suggested behavior Erase content Triangle Square Insert Action item Notes Make the strokes as horizontal as possible, and draw at least three strokes. If the height of the gesture increases, the number of back and forth strokes also needs to increase. Draw the triangle in a single stroke, without lifting the finger. Make sure that the top of the triangle points upward. Draw the square starting at the upper left corner. Draw the square with a single stroke, without lifting the pen. A complete list of application gestures recognized by Microsoft Gesture Recognizer is available on MSDN at http://msdn.microsoft.com/enus/library/ms698540(VS.85).aspx. The following code fragment of a WPF application gives you some idea about Windows-defined application gestures. The application has an ink canvas control that only accepts the enabled application gestures: triangle, square and circle. When a user runs the application and uses his finger to draw a stroke on the canvas, the inkCanvas_OnGesture method is called. If the stroke is a one-stroke triangle or square or circle and the gesture is recognized as a defined enabled gesture, the stroke is removed from the canvas. Otherwise, the stroke remains on the canvas. public Window1() { InitializeComponent(); if (inkCanvas.IsGestureRecognizerAvailable) { inkCanvas.EditingMode = InkCanvasEditingMode.InkAndGesture; inkCanvas.Gesture += new InkCanvasGestureEventHandler(inkCanvas_OnGesture); //enable only certain application gestures inkCanvas.SetEnabledGestures(new ApplicationGesture[] {ApplicationGesture.Triangle, ApplicationGesture.Square, ApplicationGesture.Circle}); } 10

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37

10
Application Gestures
In addition to gestures and flick gestures, Windows Vista also supports application
gestures. You can use Microsoft Gesture Recognizer, or create your custom gesture
recognizer or use a combination of both. Microsoft Gesture Recognizer can
recognize over forty gestures. The following table lists a few examples of gestures
recognized by Microsoft Gesture Recognizer.
Gesture
Gesture name
Suggested
behavior
Notes
Scratch-out
Erase content
Make the strokes as horizontal as possible, and
draw at least three strokes. If the height of the
gesture increases, the number of back and forth
strokes also needs to increase.
Triangle
Insert
Draw the triangle in a single stroke, without
lifting the finger. Make sure that the top of the
triangle points upward.
Square
Action item
Draw the square starting at the upper left corner.
Draw the square with a single stroke, without
lifting the pen.
A complete list of application gestures recognized by Microsoft Gesture Recognizer
is available on MSDN at
us/library/ms698540(VS.85).aspx
.
The following code fragment of a WPF application gives you some idea about
Windows-defined application gestures. The application has an ink canvas control
that only accepts the enabled application gestures: triangle, square and circle.
When a user runs the application and uses his finger to draw a stroke on the
canvas, the inkCanvas_OnGesture method is called. If the stroke is a one-stroke
triangle or square or circle and the gesture is recognized as a defined enabled
gesture, the stroke is removed from the canvas. Otherwise, the stroke remains on the
canvas.
public Window1()
{
InitializeComponent();
if (inkCanvas.IsGestureRecognizerAvailable)
{
inkCanvas.EditingMode = InkCanvasEditingMode.InkAndGesture;
inkCanvas.Gesture += new
InkCanvasGestureEventHandler(inkCanvas_OnGesture);
//enable only certain application gestures
inkCanvas.SetEnabledGestures(new ApplicationGesture[]
{ApplicationGesture.Triangle,
ApplicationGesture.Square,
ApplicationGesture.Circle});
}