1
Silverlight專家在那裏,我需要一些幫助。 我使用Deep Zoom Composer爲客戶端生成大型地圖圖像(20MB +)的Silverlight應用程序。 但客戶端不希望人們平移到MultiScaleImage中超出圖像範圍的黑色區域。 我該怎麼做? 謝謝!將平移限制在Silverlight中的可見圖像區域MultiScaleImage
Silverlight專家在那裏,我需要一些幫助。 我使用Deep Zoom Composer爲客戶端生成大型地圖圖像(20MB +)的Silverlight應用程序。 但客戶端不希望人們平移到MultiScaleImage中超出圖像範圍的黑色區域。 我該怎麼做? 謝謝!將平移限制在Silverlight中的可見圖像區域MultiScaleImage
我發現這個很髒的修復程序。當ViewPortChanged事件觸發時,我將MultiScaleImage的新更改的ViewportOrigin傳遞給下面的方法。問題是View端口是異步更改的,用戶可以看到圖像被移回到邊界。
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;
}