Bloom.Publish.PublishView.GetPreviewBounds C# (CSharp) Method

GetPreviewBounds() private method

Computes the preview bounds (since the image may be bigger than what we have room for).
private GetPreviewBounds ( ) : Rectangle
return System.Drawing.Rectangle
        Rectangle GetPreviewBounds()
        {
            double horizontalScale = 1.0;
            double verticalScale = 1.0;
            if (_previewBox.Image.Width > ClientRectangle.Width)
                horizontalScale = (double)(ClientRectangle.Width) / (double)(_previewBox.Image.Width);
            if (_previewBox.Image.Height > ClientRectangle.Height)
                verticalScale = (double)(ClientRectangle.Height) / (double)(_previewBox.Image.Height);
            double scale = Math.Min(horizontalScale, verticalScale);
            int widthPreview = (int)(_previewBox.Image.Width * scale);
            int heightPreview = (int)(_previewBox.Image.Height * scale);
            var sizePreview = new Size(widthPreview, heightPreview);
            var xPreview = ClientRectangle.Width - widthPreview;
            var yPreview = ClientRectangle.Height - heightPreview;
            var originPreview = new Point(xPreview, yPreview);
            return new Rectangle(originPreview, sizePreview);
        }