private void Autoscroll_AutoScroll(object sender, AutoScrollArgs e) { const double SCALE = .5d; if (!_isActive || _currentAutoscrollAction == null) { return; } double scale = SCALE; if (_currentAutoscrollAction.Value == CameraMovement.Pan_AutoScroll) { // Pan autoscroll is reverse direction, this has just been the convention forever, so is intuitive. But the // other actions feel more like automated versions of the standard action, so shouldn't be reversed. scale *= -1d; } // The autoscroll class calculates delta by comparing the current position (passed during mouse move) // to the position at mouse down. All of these action methods compare what they think is the current // mouse position with the previous mouse position. So I need to create a false point to hand to these // action methods. Point currentPosition = new Point(_previousPosition2D.X + (e.XDelta * scale), _previousPosition2D.Y + (e.YDelta * scale)); // Do the action switch (_currentAutoscrollAction.Value) { case CameraMovement.Orbit_AutoScroll: Vector3D currentPosition3Da = ProjectToTrackball(_eventSource.ActualWidth, _eventSource.ActualHeight, currentPosition); OrbitCamera(currentPosition, currentPosition3Da); break; case CameraMovement.Pan_AutoScroll: PanCamera(currentPosition); break; case CameraMovement.RotateAroundLookDirection_AutoScroll: Vector3D currentPosition3Db = ProjectToTrackball(_eventSource.ActualWidth, _eventSource.ActualHeight, currentPosition); RotateCameraAroundLookDir(currentPosition, currentPosition3Db); break; case CameraMovement.RotateInPlace_AutoScroll: RotateCamera(currentPosition); break; case CameraMovement.Zoom_AutoScroll: ZoomCamera(currentPosition); break; default: throw new ApplicationException("Unknown CameraMovement: " + _currentAutoscrollAction.Value.ToString()); } OnUserMovedCamera(new UserMovedCameraArgs(_currentAutoscrollAction.Value)); }
private void Autoscroll_AutoScroll(object sender, AutoScrollArgs e) { SlideCamera(e.XDelta / (-60d * 2d), e.YDelta / (-60d * 2d)); }