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,
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.
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.
Related
We have images created off a a high resolution scanner for showing defects on glass products. Our C# application is used by clients to manage defects. Many customers are having difficulties translating the image properties like actual length provided. I am working with a base image with a canvas on top. I also have a grid with a list of properties which when selected, I want to show a visual on how to translate the selection by say, drawing a line on the canvas in a manner that depicts the translation.
It turns out that the requirement was misconstrued and what was needed was creating simulations on separate images that I had to create and load. Next time I will try to think outside the box.
I need to display images on top of each other. This can either be a composite\layered image or separate images. This will typically be a larger image with smaller images on top. With the composite\layered approach the smaller images would each need to be a separate (and accessible) layer. With the separate images approach the smaller images are on top with a transparent background. With either approach the smaller images must be accessible i.e. can be moved (dragged) or deleted. The app needs to display these images together (as if it was one image) and keep track of the coordinates (position) of the smaller images.
The current (proof-of-concept) solution has a PictureBox control that displays the large image and a treeview. Nodes are dragged from the treeview to the picture box and rendered using the graphics DrawString or DrawImage methods – these draw the smaller images. The problem is that once the smaller image is drawn I cannot get back to it as a separate graphics object. The picture box “sees” it as part of the current image.
I need to do this in C# (WinForms or WPF). And the image type must be a common and open format i.e. not proprietary. Preferably no 3rd party controls.
Any suggestions\guidance?
WPF would be the technology of my choice for this project.
Drag & Drop way nicer, without flickering, better concept
Rendering directly on HW, way smoother for image manipulation
General idea of the implementation:
MVVM pattern
ViewModel holding your layer information
ItemsControl bound to the collection of Small overlay Images holding a DataTemplate which visualizes the images thour custom UserControl based on a Thumb (for drag & drop functionality) displayes the small images on top.
Easy to add functionality to drag, edit, hide each small image seperately.
The problem is that once the smaller image is drawn I cannot get back
to it as a separate graphics object. The picture box “sees” it as part
of the current image.
That behaviour is perfectly normal. GDI drawing does not work with objects. To do what you are asking, you need to track any event that can cause a change in the final image and when such an event occur, you need to draw the whole image from the begining, including the first image (assigning the background image, I guess).
May be create picture box per image. The transparent background will give the effect of single image.
I am looking for a free control in C# which allows me to show a set of images in a List like a preview (Eg PDF pages preview). I tried ListView control but it does not allow me to set bigger image size. Please advice
You can use a ListView-ImageList combination to achieve that purpose.
Just set the ImageList's ImageSize property to something large, say 96, 96 and set the ListView's LargeImageList property to the ImageList.
Have you tried using a repeater?
here's a link returned on the first page of a quick google search that demonstrates one way to do this: http://www.vbknowledgebase.com/?Id=157&Desc=Asp.Net-Image-Dropdownlist
There is the ImageListView control. (I am the owner of the project.)
How about a Panel with images in it? You can set it up to render as a scrollable div (if you're targeting ASP.NET, which I think you are), or if this is WinForms, you just set it to have scrollbars.
Understand, though, that unless you have pre-made thumbnails for your images, showing a preview of the image will require loading the whole image and downsizing it to show as a thumb. So, except for the real estate it will take, you may not be saving much by "previewing" images.
I'm a bit new to the C#-form app developing and I want know, what's the best way around at making a control that holds a list of horizontal items. In which each of these items are horizontally ruled to it's parent control, contain a thumbnail to the left and a large text block to the right of image and a smaller text block underneath that. So basically this isn't a predefined control I can find in the toolbox. Any ideas?
You could lay this out with Panels in form controls, or with WrapPanel and StackPanel in WPF.
In WindowsForms, I would create a user control that held the correct layout for a single item, then make a list of them at run time.
In WPF I would use a List control, but set the layout template to use WrapPanels and StackPanels.
WPf is the better solution long term if you don't have to coexist with winforms
I want to create a displayed array of image thumbnails in a C# Windows app.
I would like each image to be selectable for migration into a picturebox.
Has anyone built something like this?
I am trying to figure the quickest/ most efficient way to do it. I have already considered a panel with a collection of images displayed therein.
I think that you can use the Image.GetThumbnailImage() to get a thumbnail of required images and place them in picturebox controls which will be created dynamically depending on the count of images to be displayed and then use the drag and drop to drag image from a tumbnail picturebox control to a panel for displaying the full size image etc.