Question : Displaying Icon over an Image

To further my knowledge and understanding of what it is that I am creating based on my prior two questions. What I need to be able to do now is overlay an icon on an image.

I have create a form application that will do a number of things one of the forms within the application will read a folder and display the thumbnail images within that folder. Then when you double click on an image a second form will appear and allow the user to see that image in full view along with zoom (& eventually pan but that isn't working at the moment). Either way now what I would like to be able to do is state that if picture 'A.2' is clicked on icon image '004' will appear ontop image in vector '48'  or something along those lines. I would also like the icon to be able to zoom and pan with the images it is on top of if at all possible.

Not sure ow to go about this I was thinking it would just be a matter of creating a switch with the case for each image inside the folder or a series of if else statements. Any thought? If you want to see the code for the other two forms I create just let me know I just wasn't sure how important that is to this topic so I didn't post it to start with.

Answer : Displaying Icon over an Image

The code you provided in your last post should definitely go in Form2 because a) it has no bearing whatsoever on the functionality of Form1, and b) it is specific to a control on Form2.

Unless I'm missing something, you  would...

1. Add the following property to Form1 (in your form global variables list):
static string targetFileName {get; set;}
       * doing this makes accessing the value from Form2 much easier and less prone to weird behavior


2. Change the following method in Form1 as shown:
#region Full Image Popup
private void listView1_DoubleClick(object sender, EventArgs e)
{
    Point pt = listView1.PointToClient(Cursor.Position);
    ListViewItem lvi = listView1.GetItemAt(pt.X, pt.Y);

    if (lvi != null)
    {
        targetFileName = (string)lvi.Tag;
        frm.Text = lvi.Text;
        frm.Show();
    }
}
#endregion


3. Add the following line to the end of the Form2 constructor:
ShowFile(Form1.targetFileName);


4. Change the ids for "pb" in your last post to "pictureBox1".


5. Make sure you do a string.IsNullOrEmpty(Form1.targetFileName) before using targetFileName in your code... otherwise you might get an exception if the property is ever empty or null.


6. Make sure you add a "break;" after "pb.Controls.Add(tempPicturebox);" in your last post... otherwise, the loop will continue even after it's made the correct file match.


That should do it.
Random Solutions  
 
programming4us programming4us