3
votes

how i can implement pinch to zoom and multi-touch features in windows phone 8. In my application i add 3 image containers in a grid and i need to perform the above mentioned operation on my image. Please any one help me to implement the functionality in my application. Thanks in advance.

Stez

2
Hi Stez am also trying to implement multi-touch in my app but it is not working. have you solve this problem ? - kartheek
Yup it is working in ma environment without any issue, The main problem is with marketplace submission. I think you are facing the issue with missing reference. try to add all dependencies and re compile it will work. - StezPet
which version you are using am using 0.5.0 and fallowed this it raise the type MultiTouchBehavior' was not found, and version 0.6.7 there is no installation option then how can i add .dll files in to my app - kartheek
You can use the latest build from codeplex. here is the link multitouch.codeplex.com/SourceControl/changeset/view/97043 - StezPet
You please build the application in release mode and then take the dll's from release folder. And you can add that dll's to you project - StezPet

2 Answers

2
votes

Try the following library from codeplex:

https://multitouch.codeplex.com/

It performs the calculations required to scale / rotate an image when it is pinched.

1
votes

my solution which works for both WP7.5 and WP8:

XAML code

<StackPanel  x:Name="Scroll" Margin="0">
                    <Image  CacheMode="BitmapCache" Name="FrontCover"   Source="{Binding FullCover}"  >
                        <Image.RenderTransform>
                            <CompositeTransform x:Name="transform" ScaleX="1" ScaleY="1"  />
                        </Image.RenderTransform>
                        <toolkit:GestureService.GestureListener>
                            <toolkit:GestureListener   PinchDelta="OnPinchDelta" PinchStarted="OnPinchStarted" DragDelta="OnDragDelta"  />
                        </toolkit:GestureService.GestureListener>
                    </Image>
            </StackPanel>

 double initialScale;

    private void OnPinchStarted(object sender, PinchStartedGestureEventArgs e)
    {
        initialScale = transform.ScaleX;
    }

    private void OnPinchDelta(object sender, PinchGestureEventArgs e)
    {
        var curZoom = initialScale * e.DistanceRatio;
        if (curZoom >= 1 && curZoom <= 3)
        {
            transform.ScaleX = curZoom;
            transform.ScaleY = curZoom;

        }
    }

    private void OnDragDelta(object sender, DragDeltaGestureEventArgs e)
    {
        transform.CenterX = (transform.CenterX - e.HorizontalChange);
        transform.CenterY = (transform.CenterY - e.VerticalChange);

        if (transform.CenterX < 0)
            transform.CenterX = 0;
        else if ( transform.CenterX > Scroll.ActualWidth)
            transform.CenterX = Scroll.ActualWidth;
        else if (transform.CenterX > (FrontCover.Height * transform.ScaleX))
            transform.CenterX = FrontCover.Height * transform.ScaleX;

        if (transform.CenterY < 0)
            transform.CenterY = 0;
        else if (transform.CenterY > Scroll.ActualHeight)
            transform.CenterY = Scroll.ActualHeight;
        else if (transform.CenterY > (FrontCover.Height * transform.ScaleY))
            transform.CenterY = FrontCover.Height * transform.ScaleY;

    }

Think it should help others