views:

40

answers:

2

Hi,

I have a desktop application in C sharp, in which I have to show selected images in thumbnail view ( the view will be some thing like the attached image). The selected image can be deselected using x (cross) button shown on image top. Can someone suggest me how this can be accomplished. I have seen this accomplished in ASP .net. But I have to accomplish this in C#. Any clue will be greatly welcomed.

Regards,

alt text

+1  A: 

You can generate the thumbnails from the Image class in .Net (Image.GetThumbnailImage). As far as the layout you are showing here, you could use a FlowLayoutPanel, or some other type of panel (or roll your own) that would dynamically add the images to your form. From there you can highlight around the image and add your X control button in the OnPaint, just keep track of which are selected and which aren't via some container class (add the images to something like a HashSet (.Net 3.5 or higher) so that you can quickly add/remove them from the collection, and iterate it in the OnPaint.

pstrjds
If you combine my idea with VinayC's idea you would get a pretty workable solution, create a UserControl that has the image name and an image panel in it. Generate the thumbnails from your selected files and use your new control to display them. You can add properties for whether the X icon should show or not as part of the control and then allow the OnPaint of the control to manage that part. You can then use a FlowLayoutPanel to auto arrange the images as you add more of your image display controls to the panel. If I had enough reputation I would vote VinayC's comment up, its a great idea.
pstrjds
+1  A: 

My advise will be to create a custom control (or user control) that will encapsulate image thumbnail & its name. It will highlight & show cross when focused/hovered. Cross can be as simple as another image overlaid on thumbnail (showing/hiding in mouse over event). Then you just needs to create and lay out multiple instances of control in whatever manner you want.

VinayC