Embed one diagram into another

Hi

This is for Silverlight 5 + GoXam 1.3.4.5

I’d like to know if it’s possible to embed one diargam into another?
This is my scenario:

  1. User creates a tree-like diagram. They then save and close the diagram.
  2. User creates a second tree-like diagram and drag-drops the first tree diagram onto the second tree diagram. This way the second tree diagram can use the first as a reference.

The problem is I’m not quite sure as to the best of way to do this.
Should I load the first diagram into it’s own model and then manually call AddNode on the target model?

Any suggestions will be great.

Thanks

The answer is almost certainly yes, but there are a lot of possible interpretations to what you just described.

Do you have a sketch showing what you want, before and after?

Hi Walter

Thanks for responding.

Initially I create a tree diagram that can be seen in the image below:

I then save this diagram ‘MeasureTree1’ and close it.
I then create a second tree diagram and add some nodes it.

I then want to the drag the first diagram, ‘MeasureTree1’, onto the surface of the second diagram causing it to load and insert the nodes and links of the first diagram into the second diagram. Below is a screenshot of what I mean (highlighted nodes represent ‘MeasureTree1’):

Behind the scenes I will be tracking this embedded diagram so that if ‘MeaureTree1’ ever changes, those changes will be reflected in any diagram that references ‘MeasureTree1’

So the question is, what would be the best way of doing this from a GoXam perspective?

Thanks

To make my understanding clearer, what I am seeing is that you really want there to be individual nodes and links from “MeasureTree1” to be copied into “Untitled3”, and that these parts should be selectable.
If that is not the case, you would be able to display “MeasureTree1” as a single object – but I’m assuming not.

Do you want these nodes and links to be modifiable here in “Untitled3”?
If not, you can make them not Deletable and the Links not RelinkableFrom or RelinkableTo.
It might be desirable to put them all into a separate Layer, and just set Layer.AllowDelete and AllowRelink to false rather than doing so individually on each Part.
And you can turn off any in-place editing of TextBlocks and any other controls that might allow editing properties of any of those parts.

How are you keeping track of references between “diagrams”?
In other words, if “MeasureTree1” changes, how do you know which other diagrams to update?
Should “Untitled3” know that some of its parts are actually sourced from “MeasureTree1”?

If you are only showing at most one diagram at a time, you could update the nodes and links for all referenced diagrams each time the diagram becomes visible.
If there might be multiple diagrams open at once, you’ll need to update the diagram models of referring diagrams immediately when a referenced diagram such as “MeasureTree1” is changed.

I suppose if you used a Layer for each dropped diagram, you could just keep a reference from the Layer to the name of the other diagram.

By the way, when drag-and-dropping from the TreeView of diagrams, you’ll need to have the transferred data be the IDataCollection representing the data in the model of that diagram.
There are other forum topics about how to do drag-and-drop in Silverlight from a TreeView into a GoXam Diagram.
You will need to do additional work to create a new Layer for the dropped nodes-and-links, if you choose to implement that way.

Hey, are you going to make sure that the user cannot drop “Untitled3” into “MeasureTree1”?
If you need to support cycles of references, you will need to more sophisticated in how you implement such sharing of diagrams.

And of course you will probably need a way to show a list of references, and to allow the user to delete references to other diagrams.

Thanks for the detailed response, Walter
Please see my replies below:
“To make my understanding clearer, what I am seeing is that you really want there to be individual nodes and links from “MeasureTree1” to be copied into “Untitled3”, and that these parts should be selectable.
If that is not the case, you would be able to display “MeasureTree1” as a single object – but I’m assuming not.” Yes, that is correct. I want the nodes and links to be selectable but not modifiable.

“Do you want these nodes and links to be modifiable here in “Untitled3”?
If not, you can make them not Deletable and the Links not RelinkableFrom or RelinkableTo.
It might be desirable to put them all into a separate Layer, and just set Layer.AllowDelete and AllowRelink to false rather than doing so individually on each Part.
And you can turn off any in-place editing of TextBlocks and any other controls that might allow editing properties of any of those parts.” Yes, the nodes and links of the referenced diagram should not be modifiable. Your suggestion of using a seperate Layer sounds like the way to go

“How are you keeping track of references between “diagrams”?
In other words, if “MeasureTree1” changes, how do you know which other diagrams to update?
Should “Untitled3” know that some of its parts are actually sourced from “MeasureTree1”?”
My plan was to either use a group node or a special kind of node that tracks that this is a diagram reference. The next time ‘Untitled3’ is loaded, I use the Load<NodeDataType,LinkDataType>(XContainer,Func<XElement,NodeDataType>,Func<XElement,LinkDataType>) method of the Model to provide custom node loading. My custom node loader will load the latest version of ‘MeasureTree1’, replacing the copy that was saved as part ‘Untitled3’

“By the way, when drag-and-dropping from the TreeView of diagrams, you’ll need to have the transferred data be the IDataCollection representing the data in the model of that diagram.”
Not sure what you mean by this. Can you please explain?
“You will need to do additional work to create a new Layer for the dropped nodes-and-links, if you choose to implement that way.” Are there any guides or examples on how to achieve this?

“Hey, are you going to make sure that the user cannot drop “Untitled3” into “MeasureTree1”?
If you need to support cycles of references, you will need to more sophisticated in how you implement such sharing of diagrams.” Cyclical references will not be supported

“And of course you will probably need a way to show a list of references, and to allow the user to delete references to other diagrams.” My plan is to use a group node or to have the root of the embedded tree have a different visual apperance.

Thanks again

Actually, using a Group instead of a Layer would work just fine too. But then you would still need to set the desired permissions on each Part. (It occurs to me now that that might include setting Copyable to false.)

If you haven’t looked into how to do drag-and-drop from a TreeView into a Diagram, see http://www.nwoods.com/forum/forum_posts.asp?TID=3538.

What you are planning to do to load the other model into the target diagram sounds fine to me.
You could do the same when a drag-and-drop occurs – if you do this, you won’t need to use IDataCollection as the transfer data.

Thanks for all your assistance!