tags:

views:

42

answers:

0

Hello: I'd like to write an Ag control to show vertices and edges, using a spring/repulsion algorithm for layout.

Before I embark on it, I'm looking around for suggestions as the best way to go about doing it.

Requirements: Be able to Select Vertices. Be able to Select Edges. Be able to drag the Verices. Be bindable some how. Finally, hopefully, design this in such a way that parts are reusable (eg: GraphPanel) rather than one big control with only one use.

My first stab at it is to think of creating a custom GraphPanel that handles all the arranging of the vertices, and laying out the edges in between them. The second step would be to use this custompanel as the listpanel within a selector based control to give it Vertices selecting capabilities. As for selecting the edges, I've toyed with the idea of handling that separately by tracking proximity to lines in mouse movements and firing secondary events.

There are multiple problems with this approach:

Q: I can now bind Vertices....but how do I bind in Edge info? Q: In Silverlight...Panel has children. But no internalChildren. How do I draw lines in between vertices without having them affect the Children count of the Panel? Can I wrap the Panel's children somehow? What would be a way to approach this kind of panel development? Q: Or maybe graphpanel could be actually a Panel containing two canvas: one for edges, one for vertices. The top Canvas is zero sized. Is that nuts or actually a decent way to go?

An totally alternate approach that I've been suggested is to lump Vertices and Edges into one collection, and use a custom TemplateSelector to render them differently. This adds selection to all elements. Q: In that case, how would I draw the edges first, below the Vertices? Q: Sounds horribly clunky/lumpy. But is it?

As you can see....I've no idea which way to go about this problem -- which I think boils down to two domains: a) How does one create controls that bind to two different forms of data? b) How does one draw on a panel, with lines in between them, without the lines being part of the children count, etc.

Thanks very very very much.