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;
}