Posts: 19
Threads: 6
Joined: Oct 2011
Reputation:
0
I have been looking through the properties and methods you have available, but I am not sure there is one that gives me a way to measure my content once its scaled to fit. I was trying ActualContentBounds but its results are a little confusing. For example I have content that is 5423x2822 unscaled. ActualContentBounds is returning 1625x1149 which is not proportional to the starting size. If there is no way to get the scaled size, is there a way to get the to scale factor used to size the content down to fit the zoom panel? I could at least use that to calculate it.
Posts: 734
Threads: 8
Joined: Sep 2009
Reputation:
41
This is strange.
I have tested that again and the ActualContentBounds worked correctly - with preserving the proportions.
Could you please check that with the ZoomPanelDump sample - here you can replace the tiger.xaml with some bigger content for example palazz_sport.xaml and see how the ActualContentBounds is changing.
If are changing the content from code or otherwise have dynamic content than you can try to call Refresh method on ZoomPanel to recalculate the values of the properties.
You can also check that you are not using RenderTransform on your content - that does not affect measure step and therefore ZoomPanel can get wrong size measurement for its content.
You can also check that your content is really 5423x2822 in size - call Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)) on the object and check its DesiredSize - is it 5423x2822?
Hopefully any advice will help you.
Andrej Benedik
Posts: 19
Threads: 6
Joined: Oct 2011
Reputation:
0
03-13-2012, 03:49 PM
(This post was last modified: 03-13-2012, 04:02 PM by JRodman.)
I think this may be a timing issue. I am using an SvgViewbox within a ZoomPanel to load the content from an svg file. I am trying to detect the size of the content in the SvgFileLoaded event of the SvgViewbox but on first load the ActualContentBounds is coming up empty. I tested this before and after I call refresh. Does this only work once a layout pass has occurred by wpf? The size i got before may actually have been from the previous content that was loaded from what I can tell since I load several different svg files that are different sizes. The sample project I sent you has the actual content I am working with.
Maybe I am going about this the wrong way. What I am trying to accomplish is setting the zoom of the zoompanel so that the content fits the window when its rotated 90 degrees left or right. When content is not rotated, the zoompanel sizes it for me automatically. I was taking the approach of loading the content without rotation, measure the content once its scaled to fit, then doing the calculation of its rotated size to figure out how much to zoom in or out to fit the window. Do you have a better way to approach this?
Posts: 19
Threads: 6
Joined: Oct 2011
Reputation:
0
Still no luck. I tried what you suggested, but I lose my viewbox if I do. I have only a portion of my svg content visible, and the svgviewbox allows me to only show the area defined by the viewbox. By doing it this way, everything is visible. Also I found that when I apply a rotation to it, i cant seem to find the center point of elements that are clicked so I can zoom to them. I am going to send you a sample project so you can see what is happening.
Posts: 19
Threads: 6
Joined: Oct 2011
Reputation:
0
Did you receive my sample project?