private System.Drawing.Rectangle GetTargetArea()
{
if (this.Stretch)
{
return this.ClientRectangle;
}
else
{
System.Drawing.Rectangle targetArea;
if (this.imageSource == null)
{
targetArea = new System.Drawing.Rectangle(0, 0, 640, 480);
}
else
{
targetArea = new System.Drawing.Rectangle(0, 0, this.imageSource.Width, this.imageSource.Height);
}
if (targetArea.Width > this.Width || targetArea.Height > this.Height)
{
decimal ratio = Math.Min((decimal)this.Width / targetArea.Width, (decimal)this.Height / targetArea.Height);
targetArea = new System.Drawing.Rectangle(0, 0, (int)(ratio * targetArea.Width), (int)(ratio * targetArea.Height));
}
return targetArea;
}
}