public virtual RectangleF GetSourceImageRegion()
{
RectangleF region;
if (!ViewSize.IsEmpty)
{
if (SizeMode != ImageBoxSizeMode.Stretch)
{
float sourceLeft;
float sourceTop;
float sourceWidth;
float sourceHeight;
Rectangle viewPort;
viewPort = GetImageViewPort();
sourceLeft = (float)(-AutoScrollPosition.X / ZoomFactor);
sourceTop = (float)(-AutoScrollPosition.Y / ZoomFactor);
sourceWidth = (float)(viewPort.Width / ZoomFactor);
sourceHeight = (float)(viewPort.Height / ZoomFactor);
region = new RectangleF(sourceLeft, sourceTop, sourceWidth, sourceHeight);
}
else
{
region = new RectangleF(PointF.Empty, ViewSize);
}
}
else
{
region = RectangleF.Empty;
}
return region;
}