Justin
July 23, 2012, 11:29am
1
Hi Walter
Other than using a custom layer, is there any other way to a hide a group node and it’s children?
I tried the following but it only hides the group and not it’s children:
var groupPart = measureDiagram.Diagram.PartManager.FindNodeForData(group, model);
groupPart.Visibility = Visibility.Collapsed;
Thanks
Justin
walter
July 23, 2012, 12:48pm
2
You should be able to set Part.Visible = false.
Justin
July 24, 2012, 3:52am
3
Hi Walter
That works but it produces an unexpected behaviour. Consider the follow code:
private void BuildDiagram()
{
var diagram = ctlDiagram;
diagram.StartTransaction("Test");
var group = new GraphLinksModelNodeData<string>();
group.IsSubGraph = true;
group.Key = "TheGroup";
group.Text = "Grouper";
group.Location = new Point(100, 100);
diagram.Model.AddNode(group);
var n1 = new GraphLinksModelNodeData<string> { Key = "32", Location = new Point(250, 80), Text = "Accounts Payable", SubGraphKey = "TheGroup" };
var n2 = new GraphLinksModelNodeData<string> { Key = "10", Location = new Point(160, 210), Text = "Administration Expenses", SubGraphKey = "TheGroup" };
var n3 = new GraphLinksModelNodeData<string> { Key = "22", Location = new Point(330, 210), Text = "Cash", SubGraphKey = "TheGroup" };
var n4 = new GraphLinksModelNodeData<string> { Key = "16", Location = new Point(183, 329), Text = "Deprecitation", SubGraphKey = "TheGroup" };
diagram.Model.AddNode(n1);
diagram.Model.AddNode(n2);
diagram.Model.AddNode(n3);
diagram.Model.AddNode(n4);
diagram.Model.AddLink(n1, null, n2, "T");
diagram.Model.AddLink(n1, null, n3, "T");
diagram.Model.AddLink(n2, null, n4, "T");
var groupPart = diagram.PartManager.FindNodeForData(group, diagram.Model);
groupPart.Visible = false;
diagram.CommitTransaction("Test");
}
private void cmdShow_Click(object sender, RoutedEventArgs e)
{
var group = ctlDiagram.Model.FindNodeByKey("TheGroup");
var groupPart = ctlDiagram.PartManager.FindNodeForData(group, ctlDiagram.Model);
ctlDiagram.StartTransaction("test2");
groupPart.Visible = true;
ctlDiagram.CommitTransaction("test2");
}
Initially I call BuildDiagram() and then later on cmdShow_Click(). This produces the following:
Notice how the links are offset from the port they are supposed to connect to. The correct display should be this:
Thanks
Justin
walter
July 24, 2012, 6:36am
4
Although it might not look like it this is the same bug that you reported last week. Let me check on its progress.