George2
George2

Reputation: 45771

ViewportOrigin of MultiScaleImage

I am confused about the ViewportOrigin property of MultiScaleImage. I think the property should be used only for MultiScaleSubImage to assign the relative location of a sub image to the whole deep zoom region, why we need to set the ViewportOrigin property of MultiScaleImage (i.e. the whole deep zoom region)? The whole deep zoom region's left-top corner is always (0, 0), so why need to apply ViewPortOrigin property for the whole deep zoom area?

From the below MSDN link, we can learn this property apply for both MultiScaleImage and MultiScaleSubImage.

http://msdn.microsoft.com/en-us/library/cc963427(VS.95).aspx

Could anyone show me a sample when we nede to set the ViewportOrigin property of MultiScaleImage please?

thanks in advance, George

Upvotes: 0

Views: 965

Answers (1)

Raumornie
Raumornie

Reputation: 1444

Manipulating the ViewportOrigin property is how you would programatically set what part of the image you currently want to be visible. This is far more relevant if you think of an image that's zoomed in so that you can't see all of it through the viewport; say, for example, a large map. If you want to be able to select a location from a list and have the map scroll to that location, you might (and in fact I did) write something like this:

private void LocateItem(Point ItemLocation)
        {
            ZoomMap.ViewportOrigin = new Point(
                -((ZoomMap.ViewportWidth / 2) - (ItemLocation.X),
                -((ZoomMap.ViewportWidth * (ZoomMap.ActualHeight / ZoomMap.ActualWidth) / 2) - (ItemLocation.Y));
         }

Where ZoomMap is the name for my MultiScaleImage control. Hope that helps!

Upvotes: 1

Related Questions