views:

172

answers:

1

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!

A: 

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;
    }
Ivan