One Diagram, multiple views

Hi, I was wondering if it was possible to have one diagram for node and link data, etc… but have multiple views that display a subset of node/link data.

I looked over the examples and documentation, but I dont see anything that jumps out to me.

±-±-±–+
| A | B | C |
| ±---------------------------------------------------+
| |
| Diagram View 1 (partial set of nodes, links) |
| |
| |
±-------------------------------------------------------+

±-±-±–+
| A | B | C |
±-+ ±-----------------------------------------------+
| |
| Diagram View 2 (partial set of nodes, links) |
| |
| |
±-------------------------------------------------------+

etc…

Sure, just override the PartManager.Filter… methods to return false for those nodes or links that you don’t want to see.

You’ll probably want to define a custom PartManager class that has a property that tells those Filter… methods what you want to hide or what you want to show. Then for each Diagram you’ll create a separate custom PartManager with a different property value. Something like:

public class FilteredPartManager : PartManager {
public String Hide { get; set; }

protected override bool FilterNodeForData(Object nodedata, IDiagramModel model) {
if (!base.FilterNodeForData(nodedata, model)) return false;
return … some predicate looking at your nodedata …
}

… similar override for FilterLinkForData (depending on kind of model) …
}

And then when initializing:

myDiagram1.PartManager = new FilteredPartManager() { Hide="one" });
myDiagram2.PartManager = new FilteredPartManager() { Hide="two" });

Hi, the filtered part manager seems to be working :) thanks!

Suppose now I wanted I performed a node drag and drop from diagram1 to diagram2.

What event is fired when the node transitions diagram1 to diagram2? I need to update the “visible” string when this transition happens

I also noticed in my custom DropOnto method, the CopiedParts and DragOverPart are always null. In the ExternalObjectsDroped method, the SelectedPart is also null.

You’re using WPF, right? And your application is running with the permissions for using real Windows drag-and-drop, right?

There are the standard UIElement.Drag… events. There are no Diagram-specific events during the external drag.

The Node that is created in the target Diagram is based on the node data that has been (temporarily) added to the model. If your “visible” string is data-bound to your node data, perhaps you can make sure the newly created data has the string value you want.

For example, if you show the node Key in your Node DataTemplate, you’ll see that the Node being dragged in the target Diagram will have a unique Key value, which may be different than the source data Key value.

DraggingTool.CopiedParts shouldn’t be null during the call to DraggingTool.DropOnto for an external Windows drag-and-drop.

DraggingTool.DragOverPart may or may not be null, depending on where the mouse pointer is at the time of the drop. Recently we fixed a fixed a bug where if the mouse changed what Part was being dropped onto, it didn’t update the DragOverPart property. (It did drop onto the correct Part, it just didn’t update the DragOverPart property until the end when it sets DragOverPart to null.) I don’t remember off hand whether that fix is in the latest baselevel or not. But the point is that that property should be null after the DropOnto method completes.

In a successful external drop, Diagram.SelectedPart should be non-null in a Diagram.ExternalObjectsDropped event handler. However, CopiedParts and DraggedParts should be null by that time.

So if CopiedParts is null during DropOnto, and if SelectedPart is null in the ExternalObjectsDropped event handler, is drag-and-drop working at all for you?

What is the behavior expected by adding "Inclusions=“SubTree” to the dragging tool. Should the entire subtree be encapsulated in DiagramEventArgs? (for drag and drop)

I currently only see the selected node and not the subtree.

You’re talking about the source Diagram’s DraggingTool, right?

I suppose it would depend on the value of DraggingTool.CopiesEffectiveCollection. That property is false by default, but I believe that if you set it to true (on the source Diagram.DraggingTool), the data that is transferred will be the subtree(s), not just the selected node(s).

That works, thanks.

My next question is in regard to Links. The documentation for
ComputeEffectiveCollection Method states :

"Besides the Parts in the parts collection, the result collection will include all member nodes and links, links whose connected nodes are both in the effective collection, and any link labels."

Suppose :

NodeA<--LinkB-->NodeC

I want to drag and drop LinkB-->NodeC to a different diagram and have my part manager filter the drawing of the link. I would filter the visibility of the link based on if To and From Nodes are currently on the same diagram.

Unfortunately, the collection passed to drag and drop operations never contains the link. (as expected)

I experimented with an override of the ComputeEffectiveCollection method by calling the base method, and then iterating over the parts. If any of the parts were links, add to the collection. Then return. That didn't work either.

Am I missing something here? Or will I need to write custom code to achieve my desired functionality? (one idea might be creating a reflexive link, store off the previous to and from nodes and have my partmanager filter reflexive links)

Well, that’s effectively the same policy as currently implemented by copying (both for drag-and-drop and for paste) – there’s no link unless both end nodes are present in the diagram.

Thanks Walter, just wanted to make sure I was not missing something obvious.

Version 1.1 will include a sample, UpdateDemo, that demonstrates two Diagrams sharing a single model. They use different templates for nodes and for links, so that the same data has different appearances in the different diagrams.

This new sample also shows the model IDiagramModel.Changed events. And it shows the state of the UndoManager.