How do I delete all links to a node
How do I delete all links that are connected to a node when that node is deleted?
TIA
SIGN IN To post a reply.
4 Replies
AD
Administrator
Syncfusion Team
October 19, 2004 06:32 PM UTC
Hi
As noted in this Knowledgbase article, the Diagram.Model.ChildrenChangeComplete event is fired whenever a new node is added or removed. So you could use the IGraphNode Interface to detemine the links entering and leaving the Symbol and use the RemoveNodesCmd to remove the links when an instance of MySymbol is deleted. Run this sample and add a few nodes and links and select a Symbol (MySymbol) and click on the "Delete Symbols and Links" Button.
Here is the code for the Model_ChildrenChangeComplete event:
private void diagram1_Model_ChildrenChangeComplete(object sender, Syncfusion.Windows.Forms.Diagram.NodeCollection.EventArgs evtArgs)
{
if (evtArgs.ChangeType.ToString() == "Remove")
{
IGraphNode curNode = evtArgs.Node as IGraphNode;
if (curNode != null)
{
IEnumerator enumedgesEntering = curNode.EdgesEntering.GetEnumerator();
IEnumerator enumedgesLeaving = curNode.EdgesLeaving.GetEnumerator();
//RemoveNodesCmd
RemoveNodesCmd rmnodesCmd = new RemoveNodesCmd();
//NodeCollection
NodeCollection links = new NodeCollection();
//Incoming Links
ICollection edgesEntering = curNode.EdgesEntering;
while (enumedgesEntering.MoveNext())
{
Link incomingLink = enumedgesEntering.Current as Link;
links.Add(incomingLink);
}
//Leaving Links
ICollection edgesLeaving = curNode.EdgesLeaving;
while (enumedgesLeaving.MoveNext())
{
Link leavingLink = enumedgesLeaving.Current as Link;
links.Add(leavingLink);
}
//Concatatenation of the NodeCollection to the RemoveNodesCmd
rmnodesCmd.Nodes.Concat(links);
//Execute the RemoveNodesCmd
this.diagram1.Controller.ExecuteCommand(rmnodesCmd);
}
}
}
Regards
Arun
AD
Administrator
Syncfusion Team
October 23, 2004 09:43 PM UTC
Thank you for the help.
TL
Truman Lackey
July 18, 2008 05:11 PM UTC
I am trying the following in vs 6.3.0.30
if (evtArgs.ChangeType == CollectionExChangeType.Remove)
{
if (evtArgs.Element is Node)
{
IGraphNode remNode = (IGraphNode)evtArgs.Element;
foreach (IGraphEdge edge in remNode.Edges)
{
this.diagramComponent.Model.RemoveChild((Node)edge);
}
}
}
The issue I am having is that there are no edges in the Edges collection even though a link exist. How should this be done?
if (evtArgs.ChangeType == CollectionExChangeType.Remove)
{
if (evtArgs.Element is Node)
{
IGraphNode remNode = (IGraphNode)evtArgs.Element;
foreach (IGraphEdge edge in remNode.Edges)
{
this.diagramComponent.Model.RemoveChild((Node)edge);
}
}
}
The issue I am having is that there are no edges in the Edges collection even though a link exist. How should this be done?
J.
J.Nagarajan
Syncfusion Team
July 21, 2008 01:38 PM UTC
Hi Truman ,
We regret for the incovenience caused. I was able to see the issue "Node.Edges returns null when the LineConnector is exist" in 6.3.0.30. I have logged a defect report in this regard. I have forwarded this issue to our developers for more analysis. I will get back to you with more details regarding this issue on or before 23rd July,2008.
Thanks for your patience.
Regards,
Nagaraj
We regret for the incovenience caused. I was able to see the issue "Node.Edges returns null when the LineConnector is exist" in 6.3.0.30. I have logged a defect report in this regard. I have forwarded this issue to our developers for more analysis. I will get back to you with more details regarding this issue on or before 23rd July,2008.
Thanks for your patience.
Regards,
Nagaraj
SIGN IN To post a reply.
- 4 Replies
- 3 Participants
-
AD Administrator
- Oct 19, 2004 12:26 PM UTC
- Jul 21, 2008 01:38 PM UTC