Zoom to mouse point - Printable Version +- AB4D Forum (https://forum.ab4d.com) +-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4) +--- Forum: ZoomPanel (https://forum.ab4d.com/forumdisplay.php?fid=8) +--- Thread: Zoom to mouse point (/showthread.php?tid=20) |
Zoom to mouse point - marianokaplan - 11-23-2009 How difficult would it be to implement Zoom to mouse point as the default gesture? I notcied that mouse wheel just does a scale zoom but does not translate to keep the mouse pointer as the zoom center. This forces me to zoom and then pan to keep the place I want to zoom in in the same place after zooming. This would be great to have it as the default zoom behavior. Otherwise, how difficult would it be to implement as a library consumer? Thanks. RE: Zoom to mouse point - abenedik - 11-26-2009 It is quite easy to implement this behavior by yourself. You need to disable MouseWheel handling on ZoomPanel and do it yourself from the code with ZoomAndTranslateToCenter method on the ZoomPanel. The following is a sample of the implementation. XAML: Code: <Window x:Class="WpfApplication1.Window1" Code: Code: private void Window_MouseWheel(object sender, MouseWheelEventArgs e) The code simply translates the ZoomPanel to the current mouse position and than applies the zoom factor based on the mouse wheel movement. Andrej Benedik RE: Zoom to mouse point - Ronit Well - 11-28-2009 I tried out this code you guys posted but it does not seem to work. My assumption is that Zoom to Point keeps the mouse point in the same location so you can keep zooming into the same point without having to translate. This above example seems to be translating the mouse point to a different location (I guess to the center) which is not the expected behavior. So in this example, if I start zooming into the top of number 1, I would expect that point to remain the same (applying the scale zoom and necessary translate transformations). Is that possible? RE: Zoom to mouse point - abenedik - 12-04-2009 This way quite tricky :cool: Sorry for waiting so long - I working on new version of Reader3ds. So here is the solution: The XAML part is the same as before: Code: <Window x:Class="WpfApplication1.Window1" The tricky part is in the code: Code: private void Window_MouseWheel(object sender, MouseWheelEventArgs e) This should work. The code will be probably included into next version of ZoomPanel (cannot say when it will be published). Thank you for your recommendation. |