The code below is based on your piping demo. I am trying to assign some objects (anodes) by defining a subgraph that could contain one or multiple anodes.
When the model is loaded, every thing looks fine, but when I start to drag the end node both the subgraph node and the ordinary node(s) are displayed (see attached figure). Why is the supgraph node visible?
=====
private void AddPipeToModel(IPipe pipe, ItemData headNode, ItemData tailNode, ObservableCollection nodes, ObservableCollection pipes)
{
PipeData pipeData = new PipeData();
pipeData.Index = int.Parse(pipe.Index);
pipeData.FromNode = headNode;
pipeData.ToNode = tailNode;
pipeData.Colour = Force.CommonLibrary.ForceColor.GetHexColor(System.Drawing.Color.Black);
pipeData.Label = “[” + pipe.Index + “]”;
if (pipe.ProjectVersion.ShowPipeNames)
{
pipeData.LabelVisibility = System.Windows.Visibility.Visible;
}
else
{
pipeData.LabelVisibility = System.Windows.Visibility.Collapsed;
}
if (pipe.Anodes.Count > 0)
{
AnodeData anodeSubGraphNode = new AnodeData();
anodeSubGraphNode.Key = "AnodeSubGraph" + pipe.Index;
anodeSubGraphNode.IsSubGraph = true;
anodeSubGraphNode.Location = new Point(double.NaN, double.NaN);
// Add anodes
foreach (IAnode anode in pipe.Anodes)
{
AnodeData anodeNode = new AnodeData();
anodeNode.Key = "A" + anode.Index;
anodeNode.Index = int.Parse(anode.Index);
anodeNode.SubGraphKey = anodeSubGraphNode.Key;
anodeNode.Location = new Point(0, 0);
nodes.Add(anodeNode);
}
pipeData.LabelNode = anodeSubGraphNode.Key;
nodes.Add(anodeSubGraphNode);
}
pipes.Add(pipeData);
}