2

Either I'm not searching on quite the correct terms, or strangely no-one has asked about quite what I am looking for.

Put simply I'd like to have an image loaded into a user resizeable and moveable control (within the panel it belongs to). The image would need to have its opacity set. It should be resized via stretching if necessary no matter how the parent form or panel is resized. It should all be achievable fairly smoothly and on winforms.

I don't really want to re-invent the wheel here, and feel sure that something like this must have been done openly.

Strangely it seems difficult just to create a UserControl that's user resizeable and moveable at run time!?

I have a degree of understanding of drawing the image using ImageAttributes to reduce the opacity to the background, I am just wondering if there are useful resources for attempting the rest?

Thanks

Zief
  • 172
  • 1
  • 9
  • Is the image the background or in a picturebox? – Sayse Aug 15 '13 at 14:44
  • The image can be in a picture box, or if it is better to draw it with some other control? It is not really background, the reason I'd like to use the opacity option in ImageAttributes is so I can see background features with the image overlaid on them – Zief Aug 15 '13 at 14:48
  • 2
    Use WPF. You can do many things in there. – Dilshod Aug 15 '13 at 15:04
  • Whilst I need to start using WPF, the environment I'm working in is all Winforms. I am worried it would be more trouble than its worth. Surely there's already a solution to this? – Zief Aug 15 '13 at 15:14
  • 1
    @zief you can integrate WPF content into your existing winforms application via the [ElementHost](http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.elementhost.aspx). winforms is a really old technology no one cares about anymore. And even if you manage to do this in winforms, your application will probably suffer constant flickering due to the lack of hardware acceleration. – Federico Berasategui Aug 15 '13 at 15:22
  • You need to give more information on what exactly this "resizable" and "moveable" control is supposed to do. Is it supposed to be similar to some type of image viewer or thumbnail viewer? Whatever you are doing you will probably want double-buffering or a back-buffer which will allow compositing and eliminate any flickering. And yes, it does work fine on WinForms, otherwise _every_ other image viewer and application not using WPF wouldn't be working. Ignore HighCore, he should be banned from SO for always posting into WinForms questions just to trash WinForms with false information. – deegee Aug 15 '13 at 17:57
  • @HighCore. Seriously?? The list of internet links to existing software, codeproject articles, sample code, and information on a resizable image control without flicker would be way too long to post. But apparently according to you this was impossible before WPF. And what does a link to a smartphone have to do with this thread? – deegee Aug 15 '13 at 22:17
  • @deegee it seems like "resizable" and "movable" is something that you cannot understand clearly?... hmmm.. look at [this](http://stackoverflow.com/questions/15819318/how-to-create-and-connect-custom-user-buttons-controls-with-lines-using-windows/15821573#15821573) and [this](http://stackoverflow.com/a/16947081/643085) – Federico Berasategui Aug 15 '13 at 22:40
  • Chill guys, no need to argue over the two technologies. It is my understanding that WPF has been designed for graphics acceleration from the ground up. But that does not matter in this case. I'll consider that I can try doing this in WPF but since I have no experience it's a learning curve I'd rather not have with the deadline involved. I'm really surprised that nobody would have done this before in WinForms, but seems hard to find! @deegee I want the control to be resizeable and moveable by the user at runtime in the panel area. Much like loading and resizing/moving an image in image apps – Zief Aug 16 '13 at 09:32

1 Answers1

0

I decided to take the plunge and make the effort to learn WPF. It was worth it, it makes all of this much easier to do when you get your head around it. It's so much more powerful, I think I'm converted. I used this nice example too for how I can have resizeable and movable controls. http://denismorozov.blogspot.co.uk/2008/01/how-to-resize-wpf-controls-at-runtime.html

I realise this isn't an answer quite for the original question on Winforms, but since no-one else was supporting and it seems Winforms is getting left behind, I thought I'd close the issue

Zief
  • 172
  • 1
  • 9