Canguro.Commands.View.ZoomWindow.zoom C# (CSharp) Method

zoom() private method

private zoom ( Canguro activeView ) : void
activeView Canguro
return void
        private void zoom(Canguro.View.GraphicView activeView)
        {
            // use first & last points to find scale an translate values.
            float screenSize = (float)Math.Min(activeView.Viewport.Height, activeView.Viewport.Width);
            float sizeX = last.X - first.X;
            float sizeY = last.Y - first.Y;

            MouseEventArgs e = new MouseEventArgs(MouseButtons.Left, 1, (int)(first.X + sizeX / 2), (int)(first.Y + sizeY / 2), 0);
            activeView.ArcBallCtrl.OnBeginPan(e);

            e = new MouseEventArgs(MouseButtons.Left, 1, activeView.Viewport.Width / 2, activeView.Viewport.Height / 2, 0);
            activeView.ArcBallCtrl.OnMovePan(e);

            activeView.ViewMatrix = activeView.ArcBallCtrl.ViewMatrix;

            // View volume scaling
            float newScale = 0.0f;

            newScale = screenSize * activeView.ArcBallCtrl.ScalingFac / (float)Math.Max(sizeX, sizeY);

            activeView.ArcBallCtrl.ZoomAbsolute(newScale);
            activeView.ViewMatrix = activeView.ArcBallCtrl.ViewMatrix;
        }