This is a migrated thread and some comments may be shown as answers.

Controlling Connection attachment

8 Answers 163 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 25 Jun 2012, 01:50 PM
How can I do to control if a connection can be attached to a connector according to its underlying graphsource model ?

If I noticed that we can take profit from ConnectionManipulationStarted and ConnectionManipulationCompleted events to act on floating connection, I have yet many doubts. 

- ConnectionManipulationStarted provides way to control the creation of a connection from a connector (Take into account the multiplicity defined by the underlying graphsource model ...).

- ConnectionManipulationCompleted
provides way to act on the result of the manipulation. So, for example, if a diagram doesn't allow connection when target shape is null, you can remove it on this event.
It's a shame that the ConnectionUtilities.DeactivateConnectors is not a public method.

That being said, these events don't provide mechanism to act before that the connectors on target shape are activated. I like to go to another visual state if the target connector should not be used by the connection.
ConnectionUtilities lists method such as IsTargetShapeValid or  ActivateNearestConnector.
Are there any ways to intercept these calls and monitor connector activation ?

Developing my own connector, I can override the UpdateVisualStates method, but I don't have much information to do something interesting.
And MouseMove... methods are not always called.

Is there another way to follow to achieve this?

Regards,
Robert

8 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 27 Jun 2012, 12:46 PM
Hello Robert,

Thank you for sharing your scenario with us. Unfortunately at the moment the RadDiagram doesn't support it but based on your feedback, we decided to log your suggestion as a feature request in our PITS. Basically what we will try to implement is expose an event that will be fired before a connector gets activated so that you can manipulate its state and stop the activation if needed.

Do you think such an event will allow you to implement your scenario?

Greetings,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Robert
Top achievements
Rank 1
answered on 29 Jun 2012, 08:43 PM
Hi,

An event is certainly a solution.
But, using graphsource, maybe a virtual method CanLink (or CanAttach) will be another relevant solution to check if the proposed target is valid. 

Thanks for your interest.
Robert
0
Alex Fidanov
Telerik team
answered on 02 Jul 2012, 07:18 AM
Hi Robert,

 In this scenarios, you can use the event to command behaviors, or similar. Do you think this will be acceptable in your scenario?

Greetings,
Alex Fidanov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Robert
Top achievements
Rank 1
answered on 03 Jul 2012, 08:42 AM
Hi Alex,

Could elaborate a bit more on your suggestion as I don't quite see how the command would allow me to control if a connection target is eligible or not? I suppose you are thinking about leveraging the command's CanExcute method.

Rgds,
R
0
Alex Fidanov
Telerik team
answered on 03 Jul 2012, 09:44 AM
Hello,

 Currently, the only way to control this (attaching a connection to a shape) is through the event (ConnectionManipulationCompleted),and more specifically handling the event arguments. With an event to command behavior, you can pass the event args as command parameter to the command. This way, you would not need an additional command.

Kind regards,
Alex Fidanov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Robert
Top achievements
Rank 1
answered on 03 Jul 2012, 12:06 PM
Unfortunatly once the ConnectionManipulationCompleted event is raised, the connector is already attached to the shape.
We then have no other choice than removing the connector. What we would like to acheive is being able to notify to the user if he can attach to a particular shape or not before ConnectionManipulationCompleted is raised.

Rgds,
R
0
Alex Fidanov
Telerik team
answered on 03 Jul 2012, 12:32 PM
Hello Robert,

 We are aware that with our current events it is not possible to achieve this. This is why, we have logged a feature request for a different event (for example before activating a connector from Tina's update). Once we have implemented this, you would be able to use an event to command behavior and handle the event arguments and thus cancelling the action.

All the best,
Alex Fidanov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Peter
Top achievements
Rank 1
answered on 15 Jul 2012, 08:58 PM
I have the same issue:( and this solution will help.
Thanks
Peter
Tags
Diagram
Asked by
Robert
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Robert
Top achievements
Rank 1
Alex Fidanov
Telerik team
Peter
Top achievements
Rank 1
Share this question
or