By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,887 Members | 1,113 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,887 IT Pros & Developers. It's quick & easy.

GraphicUnits and scaling a picturebox

P: n/a
I have a usercontrol that contains a picturebox. The user can obtain
(creategraphics) a picturebox graphics object and draw on the picturebox.
She could do gr.GraphincInit.Millimeter and then draw using millimeters as
the measurement.

But he would still have to dimension the Picture box using pixels
(Clientsize for example). He changes the picture box dimensions via
usercontrol properties so I could scale them going in and out.

Couple of questions:
I'm quite sure the user has to tell the usercontrol what units he is using.
I mean the picturebox has no idea what has been changed in the graphics
object it gave the user. Right?

The usercontrol gets the graphics object from the picturebox and gives it to
the user. I suppose it could keep a copy of it and check to see what the
units are when it needs to. Is that correct?

Could the user obtain more then one graphics object and set them to
different units and use them alternately. The above would remove that as an
option. If this is true maybe a better way is for the user to set a units
property in the usercontrol.(He could then set it depending on which
graphics object is to be used.) Not nice but do you think this would work?

Say it's set to millimeters. When the user later sets the picturebox width
(for example) by giving milimeterers the usercontrol would convert to
inches, do a creatgraphics on the picturebox and get DPI and then calculate
the width in pixels and set it.

Seems like a lot of trouble so I want to be sure I'm not missing something
(like Dotnet can do it all by ...)
Also to set the picturebox width do I do a creatgraphics on the box or on
the usercontrol.
Thanks for any insight passed along

Nov 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.