private Size NewSize(int maxWidth, int maxHeight, int width, int height)
{
double w = 0.0;
double h = 0.0;
double sw = Convert.ToDouble(width);
double sh = Convert.ToDouble(height);
double mw = Convert.ToDouble(maxWidth);
double mh = Convert.ToDouble(maxHeight);
if ( sw < mw && sh < mh )
{
w = sw;
h = sh;
}
else if ( (sw/sh) > (mw/mh) )
{
w = maxWidth;
h = (w * sh)/sw;
}
else
{
h = maxHeight;
w = (h * sw)/sh;
}
return new Size(Convert.ToInt32(w), Convert.ToI
{
double w = 0.0;
double h = 0.0;
double sw = Convert.ToDouble(width);
double sh = Convert.ToDouble(height);
double mw = Convert.ToDouble(maxWidth);
double mh = Convert.ToDouble(maxHeight);
if ( sw < mw && sh < mh )
{
w = sw;
h = sh;
}
else if ( (sw/sh) > (mw/mh) )
{
w = maxWidth;
h = (w * sh)/sw;
}
else
{
h = maxHeight;
w = (h * sw)/sh;
}
return new Size(Convert.ToInt32(w), Convert.ToI