Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Link not moving with the node, when the moving is done programatically (Read 8514 times)
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
Link not moving with the node, when the moving is done programatically
Aug 11th, 2014 at 1:07pm
Print Post  
Hi,

I have two ShapeNodes connected through a link. One of the nodes (A) has anchor points defined, the other (B) doesn't. When I programatically relocate A, the link remains behind / is not moved. When I manually move any of these nodes though, using the mouse, the links snap back in place.

The link is created like this:
Code
Select All
var link = diagram.Factory.CreateDiagramLink(nodeWithoutCustomAnchorPoints, nodeWithCustomAnchorPoints);
link.DestinationAnchor = someIndex;
link.Dynamic = false; 



Can you please advise?

Thanks,
-Mihai
  
Back to top
 
IP Logged
 
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
Re: Link not moving with the node, when the moving is done programatically
Reply #1 - Aug 12th, 2014 at 12:57pm
Print Post  
Stoyan, thoughts?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Link not moving with the node, when the moving is done programatically
Reply #2 - Aug 12th, 2014 at 3:35pm
Print Post  
This updates the link correctly from click event for any of the nodes:

Code
Select All
var a = diagram.Factory.CreateShapeNode(10, 10, 50, 50);
var b = diagram.Factory.CreateShapeNode(110, 10, 50, 50);
b.AnchorPattern = AnchorPattern.Decision2In2Out;

var link = diagram.Factory.CreateDiagramLink(a, b);
link.DestinationAnchor = 1;
link.Dynamic = false;

private void OnNodeClicked(object sender, NodeEventArgs e)
{
	var r = e.Node.Bounds;
	r.Y += 10;
	e.Node.Bounds = r;
} 



If you are calling node.SetBounds method instead of setting the Bounds property, make sure the second bool argument (updateLinks) is set to true.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
Re: Link not moving with the node, when the moving is done programatically
Reply #3 - Aug 22nd, 2014 at 8:11am
Print Post  
Hi Stoyan,

Quote:
If you are calling node.SetBounds method instead of setting the Bounds property, make sure the second bool argument (updateLinks) is set to true.

I'm actually setting the Bounds property, but still having the issue.

I have investigated further, and the problem is really due to the container of these nodes being *programatically* relocated (I have several containers arranged with LayeredLayout).

What can I do to fix this?

Thanks,
-Mihai
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Link not moving with the node, when the moving is done programatically
Reply #4 - Aug 22nd, 2014 at 9:02am
Print Post  
Do you mean A and B nodes are in same container, and setting A.Bounds does not update the link when layout.Arrange() was applied previously?
  
Back to top
 
IP Logged
 
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
Re: Link not moving with the node, when the moving is done programatically
Reply #5 - Aug 22nd, 2014 at 9:34am
Print Post  
Hi Stoyan,

Yes, it would appear that way.

However, I have indirectly fixed the problem by applying the link arrange algorithm *after* arranging the containers, so I think we can close this ticket for now.

Thanks,
-Mihai
  
Back to top
 
IP Logged
 
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
Re: Link not moving with the node, when the moving is done programatically
Reply #6 - Sep 12th, 2014 at 12:26pm
Print Post  
Hi Stoyan,

Actually the problem reoccurred, so can you please look into it? To reproduce it:
  • Create a container node
  • Create a shape node with some anchor points, and add it into the container
  • Create a shape node without anchor points, and add it into the container
  • Create a link between the two shape nodes, with one side anchored to one of the defined anchor points
  • Move the container node programatically, like this: var newBounds = container.Bounds; newBounds.Offset(10, 0); container.Bounds = newBounds;
  • Notice how the link control points are left behind


Thanks,
-Mihai
« Last Edit: Sep 12th, 2014 at 7:25pm by mihai »  
Back to top
 
IP Logged
 
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
Re: Link not moving with the node, when the moving is done programatically
Reply #7 - Sep 15th, 2014 at 9:10am
Print Post  
Hi Stoyan,

Were you able to reproduce it?

Best Regards,
-Mihai
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Link not moving with the node, when the moving is done programatically
Reply #8 - Sep 15th, 2014 at 10:15am
Print Post  
Hi Mihai,

We could not reproduce that. Try copying your settings and event handlers to this test project to find what exactly causes it:
https://mindfusion.eu/_samples/MoveCtrTest.zip

Stoyan
  
Back to top
 
IP Logged
 
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
Re: Link not moving with the node, when the moving is done programatically
Reply #9 - Sep 16th, 2014 at 8:58am
Print Post  
Hi Stoyan,

To reproduce, please modify your method as follows:
Code
Select All
void CreateTestContainer()
{
	var ctr = diagram.Factory.CreateContainerNode(20, 50, 200, 200);
	ctr.Caption = "right-click me";

	var n2 = diagram.Factory.CreateShapeNode(120, 150, 50, 50);
	n2.AnchorPattern = null;
	n2.AttachTo(ctr, GroupAnchorStyles.Top | GroupAnchorStyles.Left | GroupAnchorStyles.Bottom);
	ctr.Add(n2);

	var n1 = diagram.Factory.CreateShapeNode(40, 70, 50, 50);
	n1.AnchorPattern = AnchorPattern.Decision1In3Out;
	ctr.Add(n1);

	var l = diagram.Factory.CreateDiagramLink(n1, n2);
	l.ControlPoints.Insert(1, new Point(105, 210));
	l.UpdateFromPoints(false, true);
} 



It basically has to do with:
* The order of the nodes creation, and
* The attaching of the first created node to the container (a fact that I did not mention initially, thinking it's not relevant).

You can then also modify the offset from 10 to 100, to make this more obvious.

Best Regards,
-Mihai
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Link not moving with the node, when the moving is done programatically
Reply #10 - Sep 17th, 2014 at 8:35am
Print Post  
This version should fix that:
https://mindfusion.eu/_beta/wpfdiag32.zip

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
Re: Link not moving with the node, when the moving is done programatically
Reply #11 - Sep 18th, 2014 at 8:31am
Print Post  
Thanks Stoyan, it works!
-Mihai
  
Back to top
 
IP Logged
 
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
Re: Link not moving with the node, when the moving is done programatically
Reply #12 - Sep 22nd, 2014 at 12:37pm
Print Post  
Hi Stoyan,

Actually, there is still a problem:
* Use the sample project, with the latest CreateTestContainer() method from this thread, and the patch you have provided
* Right-click on the container, to move it
* Then right-click on a child node from the container, to move it
* Notice how the link remains behind.

Thanks,
-Mihai
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Link not moving with the node, when the moving is done programatically
Reply #13 - Sep 23rd, 2014 at 10:51am
Print Post  
Try new build from
https://mindfusion.eu/_beta/wpfdiag32.zip

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
mihai
Junior Member
**
Offline



Posts: 86
Joined: Jul 29th, 2009
Re: Link not moving with the node, when the moving is done programatically
Reply #14 - Sep 23rd, 2014 at 1:56pm
Print Post  
Thanks Stoyan, that did the trick!
-Mihai
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint