|
-
May 22nd, 2014, 12:00 PM
#6
Re: Screen Resizing
I probably wouldn't modify what you're doing at the moment. The code I pulled my examples from had a single picturebox that filled the form, so isn't moving pictureboxes around as "players".
If you have the Background Image size mode set to Zoom, then it will automatically increase the background image (proportionally) to fit the size of the form when displayed, so you don't have to redraw the background image when it is resized, it is handled automatically. But you will have to determine what the scaling is and redraw your other things to the correct scale.
The background being automatically scaled proportionally is what may give you some issues, since it will be as large in one direction as possible, and centered in the other direction to maintain proportion. Having to account for those gaps will complicate the mouse coordinate conversion. You will have to hopefully be able to adjust the values using the same logic the form is using to resize and offset the background image. That always seems a little dangerous to me.
If, on the other hand, you allow the board to distort to fill the area (set to Stretch, not Zoom), then the mouse coordinates become trivial as I've already posted.
Of course, if you didn't use the Background image of the form, and just maintained the drawing in a bitmap and proportionally sized picturebox on the form, you could know that the background image filled the picturebox, so your mouse coordinates and image would both start at 0,0 in the upper left corner and could be computed reliably.
If you were moving just one piece at a time, then you could use invalidate, and a small rectangle area around the piece to limit the amount of data transferred from the bitmap to the screen when updating the picturebox, which should speed up the frame rate possible.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|