I\'m using a picturebox to create a visual of an instance of my truss class. I\'m creating the visual by drawing directly onto the picture box in the paint event. The method loo
Call ScaleTransform
before you do your drawing. You can calculate the desired scale factor like this:
// place this code after the calculation of maxWidth and maxHeight
// but before the drawing code
PictureBox p = (PictureBox)sender;
float scaleFactor = Math.Min(
((float)p.Width) / maxWidth,
((float)p.Height) / maxHeight
);
g.ScaleTransform(scaleFactor, scaleFactor);