ImageGlass.ImageBox.ZoomToRegion C# (CSharp) Method

ZoomToRegion() public method

Adjusts the view port to fit the given region
public ZoomToRegion ( RectangleF rectangle ) : void
rectangle System.Drawing.RectangleF The rectangle to fit the view port to.
return void
        public virtual void ZoomToRegion(RectangleF rectangle)
        {
            double ratioX;
            double ratioY;
            double zoomFactor;
            int cx;
            int cy;

            ratioX = ClientSize.Width / rectangle.Width;
            ratioY = ClientSize.Height / rectangle.Height;
            zoomFactor = Math.Min(ratioX, ratioY);
            cx = (int)(rectangle.X + (rectangle.Width / 2));
            cy = (int)(rectangle.Y + (rectangle.Height / 2));

            Zoom = (int)(zoomFactor * 100);
            CenterAt(new Point(cx, cy));
        }

Same methods

ImageBox::ZoomToRegion ( float x, float y, float width, float height ) : void
ImageBox::ZoomToRegion ( int x, int y, int width, int height ) : void
ImageBox