ConnectionManipulationCompleted issue

12 posts, 0 answers
  1. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 03 Jun 2013 Link to this post

    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...
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 06 Jun 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 07 Jun 2013 Link to this post

    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.
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 07 Jun 2013 Link to this post

    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.

  6. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 29 Aug 2013 Link to this post

    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!
  7. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 30 Aug 2013 Link to this post

    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 >>
  8. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 02 Sep 2013 Link to this post

    I guess that would be a possible workaround. Thanks.

    But, it's still a bug that needs to be fixed in your software.
  9. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 04 Sep 2013 Link to this post

    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 >>
  10. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 05 Sep 2013 Link to this post

    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.
  11. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 09 Sep 2013 Link to this post

    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 >>
  12. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 16 Sep 2013 Link to this post

    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 >>
  13. Kristoffer
    Kristoffer avatar
    158 posts
    Member since:
    Dec 2012

    Posted 17 Sep 2013 Link to this post

    Ok. So add a ConnectionManipulationCancelled event. No breaking changes :)
Back to Top
UI for WPF is Visual Studio 2017 Ready