Tag: Windows Phone

Experiments with Multi-touch: A Windows Phone Manipulation sample

I’ve just updated the project on CodePlex http://multitouch.codeplex.com to Silverlight 4 RC and added a new sample of multi-touch using Windows Phone 7 manipulation capabilities starting from this how-to available in MSDN – “How to: Handle Manipulation Events”http://msdn.microsoft.com/en-us/library/ff426933(VS.96).aspx.

The modified sample uses an Image to illustrate the possibility to move and scale objects in the Windows Phone emulator using the “ManipulationDelta” event:

These are the steps to follow in order to enable Scale and Translation gestures in a Windows Phone application:

  • Just create a new “Windows Phone Application” from Visual Studio and then add an Image control in the MainPage.xaml using this code
<Canvas x:Name="ContentCanvas" Grid.Row="1">
    <Image Source="Images/Desert.jpg" Canvas.Left="99" Canvas.Top="100"
           x:Name="image1" Stretch="Fill" Width="300">
    </Image>
</Canvas>

  • Then add an event handler for the “ManipulationDelta” event for applying a Scale and a Translate transform using the CompositeTransform available in Silverlight 4:
public MainPage()
{
    InitializeComponent();

    SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;

    ManipulationDelta += image1_ManipulationDelta;
    _compositeTransform=new CompositeTransform();
    image1.RenderTransform = _compositeTransform;
}

private CompositeTransform _compositeTransform;

void image1_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
    // Scale
    if (e.DeltaManipulation.Scale.X!=0)
       _compositeTransform.ScaleX *= e.DeltaManipulation.Scale.X;
    if (e.DeltaManipulation.Scale.Y!=0)
        _compositeTransform.ScaleY *= e.DeltaManipulation.Scale.Y;

    // Translation
    _compositeTransform.TranslateX += e.DeltaManipulation.Translation.X;
    _compositeTransform.TranslateY += e.DeltaManipulation.Translation.Y;
}

The source code is available for download from CodePlex: http://multitouch.codeplex.com

Happy Silverlighting!


Great news from MIX: Windows Phone development, Silverlight 4 RC available!

Big news today from the MIX conference in Las Vegas: a new Silverlight 4 RC release and Windows Phone development using Silverlight.

While watching the event I’ve put together some links, check it out!

 

Silverlight 4 RC

Want to know what’s new in Silverlight 4 RC? Check out this doc.

As usually all the bits can be downloaded from the Get Started section of the official site.

Other useful links:

 

Windows Phone links:

 

Happy Silverlighting!


  • Sponsored Links

  •  

    September 2010
    M T W T F S S
    « Aug    
     12345
    6789101112
    13141516171819
    20212223242526
    27282930  
  • .

    Copyright © 1996-2010 Answer My Query. All rights reserved.
    iDream theme by Templates Next | Powered by WordPress