Handling Manipulation Events

,

When a manipulation begins, the ManipulationStarted event is raised. The event handler accepts a ManipulationStartedEventArgs parameter, as shown:

void HandleManipulationStarted(object sender, ManipulationStartedEventArgs e)
{
    /* method body */
}

Contrary to the low-level TouchPoint API, there is no need to store the ID of the touch point to track its motion. In fact, the manipulation events do not offer individual touch point information. If you need that information, the low-level TouchPoint API may be more suitable.

During manipulation, the ManipulationDelta event is raised when a touch point is added to the ManipulationContainer element, or when the position of a touch point on the element changes. The event handler accepts a ManipulationDeltaEventArgs parameter, as shown:

void HandleManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
    /* method body */
}

ManipulationDeltaEventArgs provides you with the most recent and the accumulated manipulation data. The following is a list of its properties, which have not yet been covered:

Image CumulativeManipulationGets the accumulated changes of the current manipulation, as a ManipulationDelta instance. ManipulationDelta has the following two properties:

Image ScaleA Point indicating the horizontal and vertical scale amounts, relevant during multitouch manipulation.

Image TranslateA Point indicating the horizontal and vertical positional offset.

Image DeltaManipulationGets the most recent changes of the current manipulation, as a ManipulationDelta.

Image IsInertialGets whether the ManipulationDelta event was raised while a finger had contact with the element. In my experience the value of this property is always false during the ManipulationDelta event. This property is of more use during handling of the ManipulationCompleted event, as you soon see.

Image VelocitiesGets the rates of the most recent changes to the manipulation. This property is of type ManipulationVelocities, which is a class with the following two properties:

Image ExpansionVelocityGets a Point representing the rate at which the manipulation was resized.

Image LinearVelocityGets a Point representing the speed of the linear motion.

Inertia is applied automatically to a manipulation and is based on the velocity of the manipulation. Both the ManipulationCompletedEventArgs and ManipulationStartedEventArgs classes contain a Complete method, which allows you to forcibly finish the manipulation event sequence, which raises the ManipulationComplete event and prevents the application of inertia.

The ManipulationComplete event handler accepts a ManipulationCompletedEventArgs parameter, as shown:

void HandleManipulationCompleted(
            object sender, ManipulationCompletedEventArgs e)
{
    /* method body */
}

ManipulationCompletedEventArgs provides you with the final velocities and overall manipulation data. The following is a list of its properties, which have not yet been covered:

Image FinalVelocitiesGets the final expansion and linear velocities for the manipulation.

Image IsInertialGets whether the ManipulationDelta event occurred while a finger has contact with the element.

Image IsInertialGets whether the ManipulationDelta event was raised while a finger had contact with the element. If the manipulation consisted of a single touch point, it is indicative of a flick gesture.

Image TotalManipulationGets a ManipulationDelta object containing two Points representing the total scale and translation values for the manipulation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.113.208