平滑捏缩放和平移在Windows Phone 8 [英] Smooth pinch-zooming and panning on Windows Phone 8

查看:278
本文介绍了平滑捏缩放和平移在Windows Phone 8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功地实现捏缩放和挂钩到在ManipulationDelta和在ManipulationStarted事件(图像控制上)平移:

I've managed to implement pinch zooming and panning by hooking up to the ManipulationDelta and ManipulationStarted events (on an image control):

    private void image_OnManipulationDelta(object sender, ManipulationDeltaEventArgs e)
    {
        var transform = (CompositeTransform)image.RenderTransform;

        // pan
        transform.TranslateX = _translationX + e.CumulativeManipulation.Translation.X;
        transform.TranslateY = _translationY + e.CumulativeManipulation.Translation.Y;

        // zoom
        if (e.PinchManipulation != null)
        {
            transform.CenterX = e.PinchManipulation.Original.Center.X;
            transform.CenterY = e.PinchManipulation.Original.Center.Y;

            transform.ScaleX = _scaleX * e.PinchManipulation.CumulativeScale;
            transform.ScaleY = _scaleY * e.PinchManipulation.CumulativeScale;
        }
    }

    private void image_OnManipulationStarted(object sender, ManipulationStartedEventArgs e)
    {
        // the user has started manipulating the screen, set starting points
        var transform = (CompositeTransform)image.RenderTransform;
        _scaleX = transform.ScaleX;
        _scaleY = transform.ScaleY;
        _translationX = transform.TranslateX;
        _translationY = transform.TranslateY;
    }

不过,相比于Windows Phone的用户界面的其余部分的光滑感觉很平静和僵硬。有在运动没有惯性。

But the compared to the smoothness of the rest of the windows phone UI it feels very placid and stiff. There is no inertia in the movement.

有没有一种方法,使动作更加顺畅?使用动画和故事很长的路要走呢?我一直使用滚动至少获得平滑移动,但随后在ManipulationDelta事件不触发正确尝试。

Is there a way to make the movements more smooth? Is using animations and storyboards a way to go about it? I've tried using ScrollView for at least getting smooth panning but then the ManipulationDelta events are not firing correctly.

推荐答案

我知道你在说什么8,我会发布一个链接到一篇文章,涉及到7,但Windows Phone的玩弄时,这是非常有用的所以这里有云:

I know you're talking about 8 and I'll post a link to an article related to 7, but it was very useful when playing around with Windows Phone so here it goes:

<一个href="http://www.wintellect.com/cs/blogs/jprosise/archive/2011/01/19/building-touch-interfaces-for-windows-phones-part-3.aspx" rel="nofollow">http://www.wintellect.com/cs/blogs/jprosise/archive/2011/01/19/building-touch-interfaces-for-windows-phones-part-3.aspx

我不想像的从那时起多大改变......

I don't imagine that much has changed since then...

这篇关于平滑捏缩放和平移在Windows Phone 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆