public void SetTargetSize(System.Drawing.Size size) { float xRatio = (float)size.Width / this.dataSource.Width; float yRatio = (float)size.Height / this.dataSource.Height; this.SetZoomFactor(Math.Min(xRatio, yRatio)); }