PFTouch.NET: Winforms Multitouch- and Gesture-API
We are proud to present our new API for Multi-Touch and Gestures. If you have a
Multi-Touch display and Windows-7 or higher you can bind the events for these Gestures:
Pan, Zoom, Rotate, TwoFingerTap, PressAndTap:
Photo-Demo in Action
The images in our Demo-Application can be dragged, rotated and zoomed with fingure-gestures
of a Multi-Touch device. The code for handling these events is like that:
Zoom-Eventhandler:
Just set the values for ScaleX and ScaleY of the TransformElementContainer
(Winforms-Control) and the image is scaled.
private void transformElementContainer_ZoomGestureInput(object sender,
GestureEventArgs e)
{
if (e.GestureInfo.Begin)
{
dragElement = SetTopClientLocation(e.GestureInfo.Location);
}
if (dragElement != null)
{
double zf = e.GestureInfo.ZoomFactor;
dragElement.ScaleX += (float)zf - 1.0f;
dragElement.ScaleY += (float)zf - 1.0f;
transformElementContainer.Refresh();
}
}
Rotation-Eventhandler:
The same can be done for rotations of elements in the container (here a very simple
roration-handling):
private void transformElementContainer_RotateGestureInput(object sender,
GestureEventArgs e)
{
if (e.GestureInfo.Begin)
{
dragElement = SetTopClientLocation(e.GestureInfo.Location);
}
if (dragElement != null)
{
double angle = e.GestureInfo.RotationAngle * (180.0 / Math.PI);
if (e.GestureInfo.Begin)
{
rotangle = dragElement.Angle;
}
dragElement.Angle += (angle < 0.0) ? -0.5f : 0.5f;
transformElementContainer.Refresh();
}
}
If you like to develop an own control with Gesture-Events you can derive from the
TouchControl of the PFGrid-Toolkit.