views:

81

answers:

1
+2  Q: 

Grid Control

I have been tasked to create a control that has hot spots that will allow drag and drop of images. These locations will change based on what is being dragged onto the control. After dropping the image on the control it will need the ability to move to a new location (either by drag and drop or using the arrow keys).

The closest example of this functionality, which I can think of, is the Microsoft Windows desktop. When you drag an icon around it will allow you to drop it anywhere (snaps to the closest allowable hot spot) I am using .net 3.5 using C#.

I am looking for ideas to start prototyping this control.

What is the best Winform control to inherit from, or is a custom control from scratch the only way to go?

+1  A: 

I'm fairly sure you'll have to implement your own control, assuming a third-party solution doesn't already exist. As far as how your logic should go, all you need to implement is collision detection. I can't tell you specifically how this will work in your application, as that will depend on several variables (are the hotspots fixed size? Are they laid out in a symmetrical grid pattern, etc.). If they're all laid out in a symmetrical pattern, you should be able to use mathematical functions to turn a given X,Y pair into a particular hotspot. If they're of varying sizes and layouts, then you'll probably have to search through your collection of hotspot rectanges (or at least a subset of that collection) to find the rectangle that contains your point.

Adam Robinson
Thank you for the help! I've started a new control.
No problem! Please don't forget to mark the answer to your question.
Adam Robinson