Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Zoom out

Posted on 2009-05-08
3
Medium Priority
?
636 Views
Last Modified: 2013-12-17
I have a app in which a panel contains roughly 100 picture boxes all with varying size pictures which you can scroll using the panel to see them all. Is there any way that i can zoom out so you can see more of these picture boxes. And also then be able to zoom back in :)

Cheers!
0
Comment
Question by:mike_pro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Expert Comment

by:wht1986
ID: 24335630
how about setting the image mode of the picture box to Stretch Image. and then having a zoom slider to set the zoom level. at which point just change the size of the picture box and the image inside will scale automatically.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24335660
I believe you will have to loop through the panel's controls collection and set the size of each picture box to something smaller. You may then have to do some shuffling of the pb's (e.g. put 5 on one row instead of 4).
0
 
LVL 12

Accepted Solution

by:
wht1986 earned 2000 total points
ID: 24335810
I made a quick example.  I took a form and docked a trackbar at the bottom with min and max to be 1 to 20.  This will be my zoom factor divided by 10.  I docked a flow layout panel in the rest of the form.  ON form load,  I created a bunch of picture boxes from images and stored the original image size in tag.  Then as the value changed in the trackback i adjust the size of the picture boxes.
  private void Form1_Load(object sender, EventArgs e)
    {
        Assembly assm = Assembly.GetExecutingAssembly();
        string ResourceName = "WinForm_C_Sharp.Graphics.bulb_off.png";
        System.IO.Stream str = assm.GetManifestResourceStream(ResourceName);
        Image img = Bitmap.FromStream(str);
 
        for (int i = 0; i < 20; i++)
        {
            PictureBox pb = new PictureBox();
            pb.SizeMode = PictureBoxSizeMode.StretchImage;
            pb.Width = img.Width;
            pb.Height = img.Height;
            pb.Image = img;
            pb.Tag = new Point(img.Width, img.Height);
            this.flowLayoutPanel1.Controls.Add(pb);
        }
    }
 
    private void trackBar1_ValueChanged(object sender, EventArgs e)
    {
        double scale = this.trackBar1.Value / 10.0;
 
        foreach (PictureBox pb in this.flowLayoutPanel1.Controls)
        {
            Point p = (Point)pb.Tag;
            pb.Height = (int)(p.X * scale);
            pb.Width = (int)(p.Y * scale);
        }
    }

Open in new window

0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question