+3

Control Zoom in/out

Anonymous 10 years ago 0
This discussion was imported from CodePlex

veerammalkumaran wrote at 2014-08-07 12:11:

I can zoom in/out using mouse wheel. But it goes infinity. How to prevent the zoom in/out at a particular position?
IsZoomEnabled option is disabled the zoom in/out, but I want prevent the user from zoom in/out infinitely.
Is there any way to do this...?

everytimer wrote at 2014-08-08 01:31:

You can try to disabling the zoom (IsZoomEnabled) when the camera is further than a specific value, there is a property that indicates you the Camera Distance. Create an event for the wheel and play with the delta. I'm not sure about this as I've never tried it. Good luck!

veerammalkumaran wrote at 2014-08-08 08:31:

Thanks for the answer, the problem is IsZoomEnabled stops the camera distance then when should we enable the zoom.
we can disable based on the camera movements, once disabled the camera won't move then when that should be enabled.

veerammalkumaran wrote at 2014-08-08 09:47:

I done that using PreviewMouseWheel event of view port 3d (MouseWheel event doesn't trigger on helix view port 3d)
        private void viewPort3D_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
        {
            if (viewPort3D.Camera.LookDirection.Length >= 800 && e.Delta<0)
            {
                e.Handled = true;
            }

            if (viewPort3D.Camera.LookDirection.Length <= 15 && e.Delta > 0)
            {
                e.Handled = true;
            }
        }