Any plans for touch

Oct 19, 2011 at 7:01 PM

Are there currently any plans to implement touch into the control whether that be with Microsoft Surface SDK or other means?

Thank you,
Robert Lewis

Coordinator
Oct 20, 2011 at 5:32 PM

Robert,

Good one. I will open a bug for it and see how we can integrate it for Timeline. Any specific suggestions?

Oct 22, 2011 at 12:56 PM

As the project is using .Net4, you can write very minimal code to allow support for touch.  You can subscribe to the

ManipulationStarting
ManipulationDelta ManipulationInertiaStarting

events on any FrameworkElement which needs to support touch gestures such as scroll and zoom.  Insert appropriate event handler code to scroll/zoom the timeline when touch the appropriate input is detected.

Useful demo projects which demonstrate how to do this with .Net 4 are located at http://blogs.msdn.com/b/jaimer/archive/2009/11/04/introduction-to-wpf-4-multitouch.aspx#manipulationdemo.

The sample code provides demo event handler code for scrolling, zoom and rotation gestures (approprate parts summarised below):

void ManipulationStarting(object sender, ManipulationStartingEventArgs e)
{            
   e.ManipulationContainer = element;                    
}
void ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
    var element = e.Source as FrameworkElement; 
    if ( element != null ) 
    { 
        var deltaManipulation = e.DeltaManipulation; 
        var matrix  = ((MatrixTransform)element.RenderTransform).Matrix;            
        // find the old center
        Point center =  new Point ( element.ActualWidth/2, element.ActualHeight/2) ;
        // transform it to take into account transforms from previous manipulations 
        center = matrix.Transform(center); 
        // this will be a zoom
        matrix.ScaleAt(deltaManipulation.Scale.X, deltaManipulation.Scale.Y, center.X, center.Y); 
        // Rotation 
        matrix.RotateAt(e.DeltaManipulation.Rotation, center.X, center.Y);             
        // Translation (pan) 
        matrix.Translate(e.DeltaManipulation.Translation.X, e.DeltaManipulation.Translation.Y); 
       element.RenderTransform = new MatrixTransform(matrix);

       e.Handled = true;
    }
}

void ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e) {                         // Decrease the velocity of the Rectangle's movement by          // 10 inches per second every second.         // (10 inches * 96 DIPS per inch / 1000ms^2)         e.TranslationBehavior = new InertiaTranslationBehavior()         {             InitialVelocity = e.InitialVelocities.LinearVelocity,             DesiredDeceleration = 10.0 * 96.0 / (1000.0 * 1000.0)         };         // Decrease the velocity of the Rectangle's resizing by          // 0.1 inches per second every second.         // (0.1 inches * 96 DIPS per inch / (1000ms^2)         e.ExpansionBehavior = new InertiaExpansionBehavior()         {             InitialVelocity = e.InitialVelocities.ExpansionVelocity,             DesiredDeceleration = 0.1 * 96 / 1000.0 * 1000.0         };         // Decrease the velocity of the Rectangle's rotation rate by          // 2 rotations per second every second.         // (2 * 360 degrees / (1000ms^2)         e.RotationBehavior = new InertiaRotationBehavior()         {             InitialVelocity = e.InitialVelocities.AngularVelocity,             DesiredDeceleration = 720 / (1000.0 * 1000.0)         };         e.Handled = true;                   }

Hope that helps