Syncronize moving of linked symbols

Thread ID:

Created:

Updated:

Platform:

Replies:

Hello, I''m having a bit of a problem and was hoping your great team can help. I have 2 symbols on a diagram, they are connected using the LINKCMD. I would like to have the 2 symbols move together if a user changes the location of either symbol. How can I make that happen?

Hi Tim,
Have you considered grouping the two symbols and the link together so that they function as a single entity? The interactive GroupTool or the GroupCmd can be used for grouping a selection of nodes together.
If grouping will not work, another option would be to handle the Diagram.NodeMoved event, and if you detect one of the symbols being moved, then displace the other symbol as well through the same X and Y offset. The MoveCmd may be used for moving a node(s) through a specified offset.
Thanks,
Prakash Surendra
Syncfusion Inc.,

Thank you Prakash! The grouping work great, but i used the movecmd and the NodeMoved event which you suggested and it works great. Thanks again.
>Hi Tim,
>
>Have you considered grouping the two symbols and the link together so that they function as a single entity? The interactive GroupTool or the GroupCmd can be used for grouping a selection of nodes together.
>
>If grouping will not work, another option would be to handle the Diagram.NodeMoved event, and if you detect one of the symbols being moved, then displace the other symbol as well through the same X and Y offset. The MoveCmd may be used for moving a node(s) through a specified offset.
>
>Thanks,
>Prakash Surendra
>Syncfusion Inc.,
>
>

Can you please send a sample code for demonstrating this?
Rgds,
Vinod
>Thank you Prakash! The grouping work great, but i used the movecmd and the NodeMoved event which you suggested and it works great. Thanks again.
>
>>Hi Tim,
>>
>>Have you considered grouping the two symbols and the link together so that they function as a single entity? The interactive GroupTool or the GroupCmd can be used for grouping a selection of nodes together.
>>
>>If grouping will not work, another option would be to handle the Diagram.NodeMoved event, and if you detect one of the symbols being moved, then displace the other symbol as well through the same X and Y offset. The MoveCmd may be used for moving a node(s) through a specified offset.
>>
>>Thanks,
>>Prakash Surendra
>>Syncfusion Inc.,
>>
>>

I too have two nodes connected using a link. When I select these two custom nodes along with the link, i used the GroupCmd to group all the selected nodes. When I try to move the nodes using the diagram.MoveNodes, the group doesn''t move. But in the same scenario, if I add the two custom nodes alone [And not the connection] into the groupcmd object and then try to move the nodes, the nodes as a group move [without the connection]. I want to move the connection as well. How is it possible ?
Rgds,
Vinod
>Can you please send a sample code for demonstrating this?
>
>Rgds,
>
>Vinod
>
>>Thank you Prakash! The grouping work great, but i used the movecmd and the NodeMoved event which you suggested and it works great. Thanks again.
>>
>>>Hi Tim,
>>>
>>>Have you considered grouping the two symbols and the link together so that they function as a single entity? The interactive GroupTool or the GroupCmd can be used for grouping a selection of nodes together.
>>>
>>>If grouping will not work, another option would be to handle the Diagram.NodeMoved event, and if you detect one of the symbols being moved, then displace the other symbol as well through the same X and Y offset. The MoveCmd may be used for moving a node(s) through a specified offset.
>>>
>>>Thanks,
>>>Prakash Surendra
>>>Syncfusion Inc.,
>>>
>>>

Hi Vinod,
When you are attempting to move a grouping of nodes, you will have to invoke the MoveCmd on the Group object, and not on individual nodes. The Group object is a composite node itself that is made up of the child nodes in the group, and can directly set as the target of a move command. The following code shows the correct way to programmatically group two symbols connected by a link into a group, and move the whole group through an offset.
// Sym1, sym2 and lnk represent 2 symbols connected by a link
// Use the GroupCmd to create a Group containing the two symbols connected by a link
GroupCmd grpcmd = new GroupCmd();
grpcmd.Nodes.Add(sym1);
grpcmd.Nodes.Add(sym2);
grpcmd.Nodes.Add(lnk);
this.diagramComponent.Controller.ExecuteCommand(grpcmd);
// Use the MoveCmd to move the Group. The Group can be accessed through the Node.Parent property
MoveCmd movcmd = new MoveCmd(50,50);
Debug.Assert(sym1.Parent is Group);
movcmd.Nodes.Add(sym1.Parent);
this.diagramComponent.Controller.ExecuteCommand(movcmd);
Hope this helps.
Thanks,
Prakash Surendra
Syncfusion Inc.,

Hi Prakash,
I did try this out. The links are moving and that''s good news. But there is a small issue as shown below.
Consider our CustomSymbol to be something like what is shown below. The (-O) is the place were we have the ports and the links would be connected there.
Consider 2 similar symbols and a single link connected between the symbols. Now when I am moving the whole selected list as a Group as discussed in the code, all the nodes including the Symbols move but the links doesn''t get connected thru the (-O). Instead it gets connected to the rectangle part of the Symbol.
A CustomSymbol Example
|-----------|
O-| |-O
O-| |-O
O-| Custom |-O
O-| Symbol |-O
|-----------|
Awaiting your reply.
Regards,
Vinod
>Hi Vinod,
>
>When you are attempting to move a grouping of nodes, you will have to invoke the MoveCmd on the Group object, and not on individual nodes. The Group object is a composite node itself that is made up of the child nodes in the group, and can directly set as the target of a move command. The following code shows the correct way to programmatically group two symbols connected by a link into a group, and move the whole group through an offset.
>
>// Sym1, sym2 and lnk represent 2 symbols connected by a link
>
>// Use the GroupCmd to create a Group containing the two symbols connected by a link
>
>GroupCmd grpcmd = new GroupCmd();
>grpcmd.Nodes.Add(sym1);
>grpcmd.Nodes.Add(sym2);
>grpcmd.Nodes.Add(lnk);
>this.diagramComponent.Controller.ExecuteCommand(grpcmd);
>
>// Use the MoveCmd to move the Group. The Group can be accessed through the Node.Parent property
>
>MoveCmd movcmd = new MoveCmd(50,50);
>Debug.Assert(sym1.Parent is Group);
>movcmd.Nodes.Add(sym1.Parent);
>this.diagramComponent.Controller.ExecuteCommand(movcmd);
>
>Hope this helps.
>
>Thanks,
>Prakash Surendra
>Syncfusion Inc.,

Vinod,
Does this happen when you move the symbols or when you perform a copy/paste of the symbols? We are aware of such a proble when copy/pasting linked symbols, but not when moving them. I tested a few scenarios by moving a pair of linked symbols in one of the diagram samples, but was not able to reproduce the condition. If it is indeed the move that is causing the problem, please provide us with a sequence of steps that will let us view the condition.
Thanks,
Prakash Surendra
Syncfusion Inc.,

This happens after a copy/paste. After a copy/paste when I move the symbol appears like how i mentioned before.
Regards,
Vinod
>Vinod,
>
>Does this happen when you move the symbols or when you perform a copy/paste of the symbols? We are aware of such a proble when copy/pasting linked symbols, but not when moving them. I tested a few scenarios by moving a pair of linked symbols in one of the diagram samples, but was not able to reproduce the condition. If it is indeed the move that is causing the problem, please provide us with a sequence of steps that will let us view the condition.
>
>Thanks,
>Prakash Surendra
>Syncfusion Inc.,
>
>

Hi Vinod,
We already have a high priority QA report on the copy/paste issue. We will do our best to fix the problem as soon as possible, and provide a minor update with the fix soon after the 4.0 release.
Prakash Surendra
Syncfusion Inc.,

Hi Prakash,
Please see the attached doc to see what I was talking about.
Regards,
Vinod
>Hi Vinod,
>
>We already have a high priority QA report on the copy/paste issue. We will do our best to fix the problem as soon as possible, and provide a minor update with the fix soon after the 4.0 release.
>
>Prakash Surendra
>Syncfusion Inc.,
>
>

Hello Vinod,
This is interesting. We were not aware of the problem. Thank you for taking the time to put together that detailed description. I have logged a QA report on the issue, and we will do our best to fix the problem for a future release of the product. You can view the details of the QA report, and keep track of it through our web-based tracking system - http://www.syncfusion.com/Support/issues/Default.aspx.
Prakash Surendra
Syncfusion Inc.,