Hi,
I need to group selected nodes. User selects nodes than right click and selects group. User selects the node to use for grouping.
I have selected nodes and a node to use for grouping but i couldn’t make a group from them. I use the code below.??? I couldn’t find any sample codes.
ISubGraphLinksModel subGraphModel = this.objectDiagram.Model as ISubGraphLinksModel; if (subGraphModel == null) { return; } List<ContainerObject> containers = new List<ContainerObject>(); foreach (var node in this.objectDiagram.Model.NodesSource) { if (node is ContainerObject) { containers.Add(node as ContainerObject); } } if (containers.Count <= 0) { NatekMessageBox.ShowAlert(Alerts.NoContainer, ApplicationConfiguration.MessageCloseSeconds); return; } SelectContainerChildWindow window = new SelectContainerChildWindow(containers);
window.Closed += <span style="color: blue;">delegate</span>(<span style="color: blue;">object</span> parent, <span style="color: rgb43, 145, 175;">EventArgs</span> args) { <span style="color: blue;">if</span> (window.DialogResult == <span style="color: blue;">true</span>) { <span style="color: blue;">if</span> (window.SelectedContainer != <span style="color: blue;">null</span>) { window.SelectedContainer.IsSubGraph = <span style="color: blue;">true</span>; subGraphModel.SetGroupNode(window.SelectedContainer, <span style="color: blue;">null</span>); subGraphModel.AddNode(window.SelectedContainer); <span style="color: blue;">foreach</span> (<span style="color: rgb43, 145, 175;">Part</span> part <span style="color: blue;">in</span> <span style="color: blue;">this</span>.objectDiagram.SelectedParts) { <span style="color: blue;">if</span> (part.Data <span style="color: blue;">is</span> <span style="color: rgb43, 145, 175;">BaseNetworkGraphObject</span>) { <span style="color: blue;">if</span> (part.Data <span style="color: blue;">is</span> <span style="color: rgb43, 145, 175;">ContainerObject</span> && (part.Data <span style="color: blue;">as</span> <span style="color: rgb43, 145, 175;">ContainerObject</span>).Key == window.SelectedContainer.Key) { <span style="color: blue;">continue</span>; } <span style="color: rgb43, 145, 175;">BaseNetworkGraphObject</span> node = part.Data <span style="color: blue;">as</span> <span style="color: rgb43, 145, 175;">BaseNetworkGraphObject</span>; node.SubGraphKey = window.SelectedContainer.Key; window.SelectedContainer.MemberKeys.Add(node.Key); subGraphModel.AddMemberNodeKey(window.SelectedContainer, node.Key); } } subGraphModel.DoGroupNodeChanged(window.SelectedContainer); <span style="color: blue;">this</span>.objectDiagram.UpdateLayout(); } } }; window.Show();</pre>