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

ConnectionManipulationCompleted issue

11 Answers 182 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Kristoffer
Top achievements
Rank 1
Kristoffer asked on 03 Jun 2013, 07:48 AM
private void diagram_ConnectionManipulationCompleted(object sender, ManipulationRoutedEventArgs e)
{
     Here, e.Connector may be null. Why?!
}

Some times, when I drag a connection from a node and then release it before attaching to another connector, the ConnectionManipulationCompleted event is fired with its Connector set to null. It happens maybe 1 out of 10 tries, but after it has occurred it seems to happen more often until I press ESC or perform some other reset operation.

How should I interpret this? Is it a bug or is this a valid state?

UPDATE:
This event is usually not fired when I do the above. Only when it does indeed fire, this weird state is seen. I believe this event is erroneously called from within your code. Also, e.ManipulationStatus is set to ManipulationStatus.Moved. Obviously, I did not move a connection...

11 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 06 Jun 2013, 09:27 AM
Hi Kristoffer,

If I understand your description correctly, you start dragging a connection from a connector and then you release the mouse and leave the other end of the connection floating. If this is indeed the case, then the ConnectionManipulationCompleted event can't provide you with any particular e.Connector object as there is no connector attached to the floating end of the connection.

As the ConnectionManipulationCompleted is a tunneling (preview) event, it is fired just before the manipulation of a connection ends and the e.Shape and e.Connector properties hold a reference of the shape/connector where the connection is going to be attached. In your particular situation, as the end of the connection is left floating - there are no shape or connector objects that can be associated with the e.Shape or e.Connector properties.

Regarding the ManipulationStatus, please note that we currently support only 4 statuses:
  • Attaching - this is the status of a connection that is currently attaching to a shape. This is the status indicated by the ConnectionManipulationStarted event when a connection is created by dragging it out of a connector or in the ConnectionManipulationCompleted when a connection is being attached to a new connector
  • Detaching - this is the status of a connection that is currently being detached from a shape
  • Moving - this is the status of a connection that is currently being moved. Usually this is the state of a connection indicated by the ConnectionManipulationStarted while moving a floating connection
  • Moved - this is the status of a connection that is already moved. Usually this is the state of a connection indicated by the ConnectionManipulationCompleted event when it is fired after releasing the mouse to create a floating connection, as in your case.

I hope this information helps but please let me know if I'm missing something from your scenario.

Regards,
Tina Stancheva
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kristoffer
Top achievements
Rank 1
answered on 07 Jun 2013, 07:31 AM
Thanks. Your explanation is satisfactory, but the main problem here is:
"This event is usually not fired when I do the above."

The behavior of this event is non-deterministic! I can start dragging a new connection and changing my mind a couple of times, and nothing happens. Then, suddenly, this event is fired with no connector set. Sure, I can check for null but the point here is that this event is unreliable.
0
Tina Stancheva
Telerik team
answered on 07 Jun 2013, 08:21 AM
Hi Kristoffer,

On our side in a sample solution no matter how many times I end the manipulation of a connection, the ConnectionManipulationCompleted event is properly fired. However, if I hit Esc while still dragging a connection, the connection manipulation is interrupted. This means that the action is never completed and therefore the ConnectionManipulationCompleted cannot be fired and this is the expected outcome of the operation.

Please let me know if the event is behaving differently on your side. And if it is, we'll highly appreciate it if you can send a sample solution along with a screencast demonstrating your steps and the behavior you see while following them. Then we will be able to further investigate the case.

Regards,
Tina Stancheva
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kristoffer
Top achievements
Rank 1
answered on 29 Aug 2013, 08:35 AM
I MUST be able to detect when a connection is cancelled!

E.g.
1) I start dragging from connector X.
2) I hit <ESC> or simply release the mouse in the void.

If I can't detect this event it becomes impossible to successfully "do certain stuff while dragging". E.g. http://www.telerik.com/community/forums/wpf/diagram/advanced-connector-styling.aspx

Please tell me how to detect the cancel event. If it cannot be done, I hope you add this immediately. I'm afraid this has become a blocker for us. Thanks!
0
Tina Stancheva
Telerik team
answered on 30 Aug 2013, 10:18 PM
Hello Kristoffer,

At the moment in order to detect a ConnectionManipulation being cancelled through the keyboard, you can add a KeyDown event handler and a bool value to track the manipulation status.

Please try the approach demonstrate below and let us know if it helps:
public MainWindow()
{
    InitializeComponent();
 
    this.diagram.AddHandler(RadDiagram.KeyDownEvent, new KeyEventHandler(OnDiagramKeyDown), true);
}
 
private bool isManipulatingConnection;
private void ConnectionManipulationStarted(object sender, Telerik.Windows.Controls.Diagrams.ManipulationRoutedEventArgs e)
{
    this.isManipulatingConnection = true;
}
private void ConnectionManipulationCompleted(object sender, Telerik.Windows.Controls.Diagrams.ManipulationRoutedEventArgs e)
{
    this.isManipulatingConnection = false;
}
 
private void OnDiagramKeyDown(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Escape && this.isManipulatingConnection)
    {
        // Connection cancelation.
        this.isManipulatingConnection = false;
    }
}

Regards,
Tina Stancheva
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Kristoffer
Top achievements
Rank 1
answered on 02 Sep 2013, 09:24 AM
I guess that would be a possible workaround. Thanks.

But, it's still a bug that needs to be fixed in your software.
0
Tina Stancheva
Telerik team
answered on 04 Sep 2013, 03:34 PM
Hi Kristoffer,

Thank you for getting back to us. We will definitely further discuss your feedback and see whether we can expose an event that lets you detect a connection manipulation being cancelled through the keyboard. Also we will monitor our customers demand for such an implementation and we will try to prioritize the task based on that information.

Regards,
Tina Stancheva
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Kristoffer
Top achievements
Rank 1
answered on 05 Sep 2013, 07:22 AM
Thanks, but no. This is not a feature request. I'm pinpointing a BUG!

You need to explicitly call the ConnectionManipulationCompleted event when you handle the Escape key and have cancelled the connection manipulation. This is what you do when the mouse is released in the void. Why not do it when pressing the Escape key?

During the years I've seen hundreds of drag-drop implementations and all of them have handled the Escape key as described.
0
Tina Stancheva
Telerik team
answered on 09 Sep 2013, 09:47 PM
Hello Kristoffer,

I can absolutely see your point here. Unfortunately the ConnectionManipulationCompleted event was not designed to support this case. Basically this event is designed to notify a user only after a connection manipulation has successfully completed. And as the cancellation of a connection creation does not qualify as a successful end of a manipulation, the event isn't raised while hitting the Esc key.  

But based on your feedback, our developers will further consider whether the ConnectionManipulationCompleted event implementation can be successfully changed to reflect the Esc cancellation or if there is a better approach we can implement to facilitate this scenario. I will keep you posted on the progress of the task.

Regards,
Tina Stancheva
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Tina Stancheva
Telerik team
answered on 16 Sep 2013, 11:21 PM
Hello Kristoffer,

I want to follow up on your feedback. We discussed your suggestion, however as the ConnectionManipulationCompleted event was not designed to handle a cancellation of connection creation, we cannot modify it without introducing breaking changes.

This is why we decided that it would be better to consider a different approach. We absolutely agree with you that RadDiagram should notify you when a connection creation is cancelled with the Esc key and therefore I logged a task in our PITS to implement such a functionality.

Regards,
Tina Stancheva
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Kristoffer
Top achievements
Rank 1
answered on 17 Sep 2013, 07:15 AM
Ok. So add a ConnectionManipulationCancelled event. No breaking changes :)
Tags
Diagram
Asked by
Kristoffer
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Kristoffer
Top achievements
Rank 1
Share this question
or