I'm looking to add a 'mapview' type control to my project. It must have a 'main map' image with clickable transparent rectangles with borders and icons/images that can be animated when an event occurs.
What would be the best way of achieving this using windows forms in C#?
My first thought was to use a picture box with other items on top of it but I might run into problems with transparency etc.
Are there any libraries or anything out there that would be able to achieve this?
No need for a library, really:
I would go for a regular doublebuffered Panel
subclass or even a PictureBox
subclass for the board/map along with a movable Label
or Panel
subclass fpr the rectangles/items.
Important: Make sure the Labels
are not just 'put on top' of the PictureBox
but really nested!! (lbl.Parent = pbox). Then transparency will work just fine..
Since PictueBox
is not a 'container', to nest a control in it you need code. But since you probably want to create them dynamically this is not an issue anyway.
This assumes that the rectangles are not overlapping! For overlapping controls transparency in winforms will not work.
The clearer you understand the 'animate when event' part the easier the rest of the code will be..
Since you mention 'animation', a word of warning: Simple animation, especially in reponse to a user action is doable; for more classy animation you may run into the limits of winforms.