Grouping objects in GoView


I am using ProtoApp as a starting point for my application. I need the ablility to group 3 objects (images) together and have them act as a single node. How should I do that? Do any of the sample applications show how this is done?


You could just add a couple of GoImages to the GraphNode, each with the size and position you want. (Remember to make them not Selectable, unless you really want users to be able to select them individually.)
You might prefer replacing the GraphNode.Icon with a GoGroup consisting of three GoImages. That way the selection handle(s) will include all three images together.
If you need to worry about resizing, either by the user or programmatically, you should override LayoutChildren to resize and reposition everything the way you want.
If you add fields to GraphNode to refer to your additional objects, be sure to keep them up-to-date when the node is copied (override CopyChildren) or when the child object is removed from the node (override Remove).
There are lots of example classes that do these kinds of things, so you can learn from them.


Is there an example that shows how I can do an automatic grouping if a user places an object next to another object?


Well, not really. I do have an internal example which customizes the dragging tool to accumulate “StickyShapes” if they are close to each other. This does not use GoGroups. The code isn’t really good enough to be of “example” quality.
You might get what you want by implementing a GoView.SelectionMoved event handler that detects whether the objects in the Selection should be grouped together with any nearby objects. If so, it should do something similar to the group command in SubGraphApp.


I’m thinking that this is something that other designers have also tried to do so I am concerned that maybe I am approaching this the wrong way. I’m going to send you an email with a better description of what I am trying to do.


Have you looked at what the OrgCharter sample does?
When you drop a node onto another node, it automatically moves the new node to be below the original node (i.e., a larger Y coordinate) and creates a link between them. This is true both for external drag-and-drops as well as internal moves.
You could add the dropped object (if valid according to whatever criteria you have) to your node. Your node should override LayoutChildren to make sure everything is sized and positioned correctly for all possible configurations of added objects.

Did you get email I sent last week?


Yes, and I replied here. Sorry about the confusion.


No problem. I’ll check out your suggestion.