-
January 8th, 2005, 07:04 AM
#1
Zoom In and Out in PictureBox Windows forms control
I've a windows form, on which a picturebox is placed. I've loaded images into the picturebox. I've implemented the Zoom In and Zoom out functinality. Now my problem is when I zoom in, the picturebox is not spreading equally in the form. I mean the distance between picturebox and the container form should be equal, on four sides, as I zoom in and out ( the picturebox should be exactly centered). How can I achive this? Any help? Thanks in advance.
Here is the piece of code for Zoom In and Out
For Zooming In :
pictureBox1.Top= (int)(pictureBox1.Top - (pictureBox1.Height * 0.025));
pictureBox1.Left = (int)(pictureBox1.Left - (pictureBox1.Width * 0.025));
pictureBox1.Height = (int)(pictureBox1.Height + (pictureBox1.Height* 0.05));
pictureBox1.Width = (int)(pictureBox1.Width + (pictureBox1.Width * 0.05));
For Zooming Out :
pictureBox1.Top = (int)(pictureBox1.Top + (pictureBox1.Height * 0.025));
pictureBox1.Left = (int)(pictureBox1.Left + (pictureBox1.Width * 0.025));
pictureBox1.Height = (int)(pictureBox1.Height - (pictureBox1.Height* 0.05));
pictureBox1.Width = (int)(pictureBox1.Width - (pictureBox1.Width * 0.05));
-
January 8th, 2005, 06:42 PM
#2
Re: Zoom In and Out in PictureBox Windows forms control
Usually for scrolling around like this I'd create a user control with a Panel with DockStyle = Fill which has a picturebox control which wholly encompasses the panel's area.
Then when you zoom in resize the picturebox to the correct dimensions and call 'PerformLayout' on the Panel.
This will cause it's scrollbars to update and enable a user to scroll around your picturebox.
Then add the user control to your form.
I hope you get what I mean.
Darwen.
-
July 12th, 2014, 05:04 AM
#3
Re: Zoom In and Out in PictureBox Windows forms control
Originally Posted by darwen
Usually for scrolling around like this I'd create a user control with a Panel with DockStyle = Fill which has a picturebox control which wholly encompasses the panel's area.
Then when you zoom in resize the picturebox to the correct dimensions and call 'PerformLayout' on the Panel.
This will cause it's scrollbars to update and enable a user to scroll around your picturebox.
Then add the user control to your form.
I hope you get what I mean.
Darwen.
Hi Darwen, this does not keep the cursor(mouse) zoom position.
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
|