简体   繁体   中英

Making a slideshow viewer, handling events fired from arbitrary controls

I am extending an image viewer to support slideshow functionality. I have used a split container to separate the main form into two panels.

  • Panel on the left will contain a list of thumbnails
  • Panel on the right will contain the full-size image

Each panel supports drag and drop. When I drop an image file into the thumbs panel, it should create a thumbnail and display it on the panel, starting from the top and working its way down as more images are dropped. By default, the first image available will be shown on the panel to the right.

When I select another thumbnail, the viewer will display the full-size image.

What is a good way to implement this list of thumbnails? I've looked through the list of controls available but can't decide which one is most appropriate for this.

I was thinking of dynamically creating PictureBox objects, but then it didn't seem obvious how after I register a Click event, how I would identify which PictureBox the event was sent from.

I am looking for one of two possible types of answers

  • going ahead with the PictureBox creation idea, but understanding how I should be handling the Click events to correctly show the desired image.
  • an alternative suggestion for displaying the list of thumbs (if the PictureBox idea is not feasible)

You can tie the event handler to multiply controls and identify them by the "sender" parameter. It always points to the event sender.

void OnClick(object sender, KeyEventArgs e) {
    PictureEdit editor = (PictureEdit)sender;
}

Sub OnClick(ByVal sender As Object, ByVal e As KeyEventArgs)
    Dim editor as PictureEdit = CType(sender, PictureEdit)
End Sub

Alternatively, you can create your own (not that complex) control divided into rectangular areas displaying images.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM