仅将平移限制为 Silverlight MultiScaleImage 中的可见图像区域

发布于 2024-08-17 06:45:42 字数 152 浏览 6 评论 0原文

Silverlight 专家在那里,我需要一些帮助。 我使用 Deep Zoom Composer 为客户生成大型地图图像(20MB+)的 Silverlight 应用程序。 但客户不希望人们平移到 MultiScaleImage 中图像边界之外的黑色区域。 我怎样才能做到这一点? 谢谢!

Silverlight experts out there, I need some help.
I used Deep Zoom Composer to generate the Silverlight application for a large map image(20MB+) for a client.
But the client does not want the people to pan to the black areas that are out of the bounds of the image in the MultiScaleImage.
How can i do that?
Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

装迷糊 2024-08-24 06:45:42

我对此发现了一些肮脏的修复。当 ViewPortChanged 事件触发时,我将 MultiScaleImage 的新更改的 ViewportOrigin 传递给下面的方法。问题在于视图端口是异步更改的,用户实际上可以看到图像被移回其边界。

public void SetViewportOrigin(Point point)
    {
        Point bottomRight = ZoomImage.ElementToLogicalPoint(new Point(ZoomImage.ActualWidth / ZoomImage.ViewportWidth - ZoomImage.ActualWidth, ZoomImage.ActualWidth / (ZoomImage.ViewportWidth * 1.33184438 /*ZoomImage.AspectRatio*/) - ZoomImage.ActualHeight));
        bottomRight.X -= ZoomImage.ViewportOrigin.X;
        bottomRight.Y -= ZoomImage.ViewportOrigin.Y;

        if (point.X < 0)
        { //left edge
            point.X = 0;
            Debug.WriteLine("left edge");
        }
        else if (point.X > bottomRight.X)
        {//right edge
            point.X = bottomRight.X;
            Debug.WriteLine("right edge");
        }

        if (point.Y > 1.0)
        {//bottom edge

            point.Y = 1.0;
            Debug.WriteLine("bottom edge1");
        }

        if (point.Y < 0)
        {//top edge
            point.Y = 0;
            Debug.WriteLine("top edge");
        }
        else if (point.Y > bottomRight.Y) //bottom edge
        {
            point.Y = bottomRight.Y;
        }

        ZoomImage.ViewportOrigin = point;
    }

I found little dirty fix for this. When the ViewPortChanged event fires, I pass the newly changed ViewportOrigin of the MultiScaleImage to the method below. The problem is that tha View Port is changed asynchronously, and the user can actually see the image being moved back to its bounds.

public void SetViewportOrigin(Point point)
    {
        Point bottomRight = ZoomImage.ElementToLogicalPoint(new Point(ZoomImage.ActualWidth / ZoomImage.ViewportWidth - ZoomImage.ActualWidth, ZoomImage.ActualWidth / (ZoomImage.ViewportWidth * 1.33184438 /*ZoomImage.AspectRatio*/) - ZoomImage.ActualHeight));
        bottomRight.X -= ZoomImage.ViewportOrigin.X;
        bottomRight.Y -= ZoomImage.ViewportOrigin.Y;

        if (point.X < 0)
        { //left edge
            point.X = 0;
            Debug.WriteLine("left edge");
        }
        else if (point.X > bottomRight.X)
        {//right edge
            point.X = bottomRight.X;
            Debug.WriteLine("right edge");
        }

        if (point.Y > 1.0)
        {//bottom edge

            point.Y = 1.0;
            Debug.WriteLine("bottom edge1");
        }

        if (point.Y < 0)
        {//top edge
            point.Y = 0;
            Debug.WriteLine("top edge");
        }
        else if (point.Y > bottomRight.Y) //bottom edge
        {
            point.Y = bottomRight.Y;
        }

        ZoomImage.ViewportOrigin = point;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文