Overview

A gesture is a specific set of input that can be configured to trigger a command. An example of a gesture would be the click of a button or the flick of a mouse.

Included Gestures

Extending Gestures

To create a new gesture inherit from the abstract Gesture class and decorate with the GestureAttribute. The IsGestureActived method must be implemented -- this will be called each time a device is updated. All user defined properties should must be exposed through public properties and decorated with the UserPropertyAttribute. If the type of a property is not a primitive type a property converter and a property setter user control must be supplied. Quantified gestures must implement the IQuantifiedGestures interface and supply values to commands via a weakly typed string dictionary.

Sample

[PartCreationPolicy(CreationPolicy.NonShared)]
[Gesture("ButtonDownGesture")]
public class ButtonDownGesture : Gesture
{
    Boolean _isPressed;

    [UserProperty]
    public ButtonDeviceComponent Button { get; set; }

    public ButtonDownGesture()
    {
        _isPressed = false;
    }

    public override Boolean IsGestureActivated()
    {
        if (Button == null)
            return false;

        if (Button.State != ButtonState.Down)
        {
            _isPressed = false;
            return false;
        }

        if (_isPressed)
            return false;

        _isPressed = true;
        return true;
    }
}