Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Problem when deleting a node (Read 2997 times)
nezzy
YaBB Newbies
*
Offline



Posts: 25
Joined: May 31st, 2010
Problem when deleting a node
Dec 7th, 2010 at 9:31am
Print Post  
Hi.
I have a diagram with a lot of nodes, my are custom made but that's not the problem. These nodes are linked together.
When the user want's to delete a node and are using the "delete"-button on the keyboard, I would like the diagram to be re-drawn and the node next in line to be moved closer to the previous node and a new link to be created between the remaining nodes.
But what happens is that in the nodeDelete event the e.Node doesn't have any links connected to it any more. The GetAllLinks method contains no links.
Even more strange is that after the nodeDelete event, fires the linkDelete event. And these links have it's Destination and Origin nodes value intact.
E.G node1-node2-node3-node4
user user marks node2 and press the delete-button.
Result after delete:
node1 node3-node4
I would like this result
node1-node3-node4
Any ideas?
Best Regards
Anders
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem when deleting a node
Reply #1 - Dec 7th, 2010 at 10:09am
Print Post  
Hi, are you using applet mode?
  
Back to top
 
IP Logged
 
nezzy
YaBB Newbies
*
Offline



Posts: 25
Joined: May 31st, 2010
Re: Problem when deleting a node
Reply #2 - Dec 7th, 2010 at 10:17am
Print Post  
Hi again.
No, we are not using applet mode.
We are using image mode.
Regards
Anders
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem when deleting a node
Reply #3 - Dec 7th, 2010 at 4:29pm
Print Post  
Hi,

The event is raised after the node is removed from the diagram and disconnected from its links so it's a bit late to get them from NodeDeleted. We will try to add in the next couple of days a NodeDeleting event raised before the node is removed and you would be able to access the adjacent nodes from there.

Stoyan
  
Back to top
 
IP Logged
 
nezzy
YaBB Newbies
*
Offline



Posts: 25
Joined: May 31st, 2010
Re: Problem when deleting a node
Reply #4 - Dec 7th, 2010 at 4:51pm
Print Post  
Many thanks.
Regards
Anders
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem when deleting a node
Reply #5 - Dec 8th, 2010 at 11:09am
Print Post  
Our developer has added the event. What .NET version are you using?
  
Back to top
 
IP Logged
 
nezzy
YaBB Newbies
*
Offline



Posts: 25
Joined: May 31st, 2010
Re: Problem when deleting a node
Reply #6 - Dec 8th, 2010 at 12:04pm
Print Post  
Hi.
We are using .NET 4.0
BR
Anders
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem when deleting a node
Reply #7 - Dec 8th, 2010 at 1:47pm
Print Post  
On the PM page you can find an updated .NET 4 build that adds NodeDeleting and LinkDeleting events to DiagramView. You could handle NodeDeleting like this:

Code
Select All
protected void diagramView_NodeDeleting(object sender, NodeValidationEventArgs e)
{
	var diagram = diagramView.Diagram;
	var next = e.Node.OutgoingLinks.Count > 0 ? e.Node.OutgoingLinks[0].Destination : null;
	var prev = e.Node.IncomingLinks.Count > 0 ? e.Node.IncomingLinks[0].Origin : null;
	if (prev != null && next != null)
		diagram.Factory.CreateDiagramLink(prev, next);

	while (next != null)
	{
		var bounds = next.Bounds;
		bounds.Offset(-e.Node.Bounds.Width - 20, 0);
		next.Bounds = bounds;
		next = next.OutgoingLinks.Count > 0 ? next.OutgoingLinks[0].Destination : null;
	}
}
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint