ImageGlass.ImageBox.GetPreferredSize C# (CSharp) Method

GetPreferredSize() public method

Retrieves the size of a rectangular area into which a control can be fitted.
public GetPreferredSize ( Size proposedSize ) : Size
proposedSize System.Drawing.Size The custom-sized area for a control.
return System.Drawing.Size
        public override Size GetPreferredSize(Size proposedSize)
        {
            Size size;

            if (!ViewSize.IsEmpty)
            {
                int width;
                int height;

                // get the size of the image
                width = ScaledImageWidth;
                height = ScaledImageHeight;

                // add an offset based on padding
                width += Padding.Horizontal;
                height += Padding.Vertical;

                // add an offset based on the border style
                width += GetImageBorderOffset();
                height += GetImageBorderOffset();

                size = new Size(width, height);
            }
            else
            {
                size = base.GetPreferredSize(proposedSize);
            }

            return size;
        }
ImageBox