1

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

4

1 回答 1

0

我发现了一点肮脏的解决方法。当 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;
    }
于 2010-03-30T19:37:46.217 回答