I find the ZoomCanvas really helpful for my project - great work!
However, I am a bit puzzled by the FlyTo method: In what coordinate system does it expect the rect parameter to be?
I tried screen coordinates, but it did not produce the desired effect:
For example, specifying (0, 0, 640, 480) I would expect the resulting area to include the upper left area of what was displayed on the screen before. The scale is set correctly, but the position is not.
I played around with the ScreenToWorld and WorldToScreen method, without being too successful, though.
After experimenting and looking at the source code, I found the following to work - although it does not seem the most straight-forward approach:
// position and size of element to fly to and show fullscreen
double top, left, width, right;
double scale =
Math.Max(MyZoomCanvas.RenderSize.Width / width, MyZoomCanvas.RenderSize.Height / height);
Point canvasCenter =
new Point(MyZoomCanvas.RenderSize.Width / 2, MyZoomCanvas.RenderSize.Height / 2);
Point center = new Point(
canvasCenter.X + (canvasCenter.X - left - width / 2) * scale,
canvasCenter.Y + (canvasCenter.Y - top - height / 2) * scale);
center = new Point(-center.X, -center.Y);
center = new Point(center.X - width / 2, center.Y - height / 2);
Vector size = new Vector(width, height);
MyZoomCanvas.FlyTo(rect, 0, TimeSpan.FromMilliseconds(500));