Silverlight的专家在那里,我需要一些帮助。 我用深度缩放作曲以产生用于大地图图像(20MB +)用于客户端的Silverlight应用程序。 但客户不希望人们对平移是出在MultiScaleImage图像的边界的黑色区域。 我怎样才能做到这一点? 谢谢!

有帮助吗?

解决方案

我发现有点脏定为这。当ViewPortChanged事件触发,我通过MultiScaleImage的新改变ViewportOrigin下面的方法。的问题是,THA浏览端口异步地改变,并且用户可以实际看到图像被移动回其边界。

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;
    }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top