views:

384

answers:

1

Hello everyone,

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

+1  A: 

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!

Raumornie
Thanks Raumornie, I think MultiScaleImage (looks like a container) contains a lot of sub imgages (MultiScaleSubImage) as we made in Deep Zoom Composer. My confusion is when we set the ViewportOrigin of the container, what is the impact of containing sub images?
George2
Ah. Good clarification, but really, it's the same thing. In the case of using a collection rather than a composite or a large single image, manipulating the MultiScaleImage treats the entire collection as a composite, though that's probably not what you want to do if you created a collection in the first place (although I'm sure someone could think of an example). The metaphor that strikes me is referring to a Dictionary<Key, Value> by index rather than by Key; it works and you can make it do what you want, but it's likely missing the point.
Raumornie
Thanks Raumornie, could I understand in this way? The top-left corner of displayable area of Deep Zoom is always (0, 0), for the collection of images (MultiScaleImage object), we set its ViewportOrigin to set its relative position according to the top-left corcer of the whole displayable area of Deep Zoom? My previous confusion is, I think the top-left corner of the collection of images (not the Deep Zoom displayable area) is always (0, 0). Not sure whether I have made myself understood. My current understanding correct? Any comments?
George2
"displayable area of Deep Zoom" -- I mean the fixed size of area which end user could see and manipulate collections of deep zoom image. Another question is for the collection of images in an MultiScaleImage object, ViewportWidth of the images are all the same and the only differences between them are ViewportOrigin?
George2
"displayable area of Deep Zoom" -- in my points, I am referring to the width and height property of MultiScaleImage.
George2
I think your understanding of ViewportOrigin is essentially correct. As far as ViewportWidth goes, it's essentially how you set the zoom level of the images programmatically (ZoomAboutLogicalPoint sets this relatively, ViewportWidth sets it absolutely).Might not be a bad idea to set up a test app that lets you manipulate these properties directly, just to watch their effects, both with a collection and with a composite. I made several test apps while trying to understand Deep Zoom and they helped immensely.
Raumornie
My most confusion is, 1. ViewportOrigin is not in the range of [0, 1], I think it should be logical coordiniate, so should be in range of [0, 1]. Any comments? 2. I do not quite understand what is the meaning of calculation "ZoomMap.ViewportWidth / 2) - (ItemLocation.X", could you explain what you get from this formula please?
George2