Cut/Copy/Paste with GraphSource

6 posts, 0 answers
  1. Steve
    Steve avatar
    8 posts
    Member since:
    Jun 2013

    Posted 27 Sep 2013 Link to this post

    Hello,

    I am trying to add cut/copy/paste functionality to my RadDiagram, which is databound (MVVM) with a custom GraphSource.  The problem I have is that in the DeserializeNode method, it appears that a node on my GraphSource has already been created.  I was able to correctly deserialize my underlying model, but if I let add the item to my model, INPC/INCC events fire such that another item is also added to the GraphSource, so the result is two items in the graphsource, one of which my underlying model has no idea about.

    I looked at implementing my own IDataTransferService so that I could override the Paste and not create a node on the graph, but this looks rather cumbersome.  

    Is there an easier way to handle the paste such that I can update my model, and the node will be added to the view when the GraphSource is updated?

    Thanks,
    Steve
  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 02 Oct 2013 Link to this post

    Hello Steve,

    Please note that the Cut/Copy/Paste operations are supported by the RadDiagram framework out of the box. Hence, it is not needed bothering implementing such functionality manually. Also, the RadDiagram exposes commands that can be used.

    You can take a look at this article where we demonstrated how these commands can be used. Also, please note that the serialization feature is available in the SerializableGraphSourceBase.

    I hope that this information is helpful.

    Regards,
    Pavel R. Pavlov
    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Steve
    Steve avatar
    8 posts
    Member since:
    Jun 2013

    Posted 02 Oct 2013 Link to this post

    Pavel,

    I am aware that they are already implemented.  My issue is that I have an underlying data model that needs to be notified when something is pasted.  The only way I could see to do that was to hook into my GraphSource's InternalItems CollectionChanged event.  However, when I do this I do not know if it was due to an add at the UI level, or if the collection changed because my underlying data model changed it (I could probably hack something to figure this out, but it isn't desirable).  Also, I would prefer to handle the paste in the data model first, to evaluate business rules, and then have the UI updated when I update the graph source.  With the current implementation I don't see a way to do this. Is this possible?

    Steve
  5. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 07 Oct 2013 Link to this post

    Hi Steve,

    Thank you for elaborating more on you scenario. I now understand your requirements. And I am happy to inform you that there is straightforward way to achieve your requirements.

    Since you need to customize the serialization of the RadDiagram, you can use the SerializableGraphSourceBase class to create your custom GraphSource. Furthermore, you will be able to override the SerializeNode(), DeserializeNode(), SerializeLink(), DeserializeLink() methods and implement your custom logic in your GraphSource.

    Please give this approach a try and let me know if you need any further assistance.

    Regards,
    Pavel R. Pavlov
    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 >>
  6. Ishan
    Ishan avatar
    1 posts
    Member since:
    Sep 2013

    Posted 16 Oct 2013 Link to this post

    Hi,

    I also have the same problem and tried the ISerializableGraphSource, but had no luck. The object does get added in the model, but the properties like position does not get updated when I move the objects over the diagram.

    Regards,
    Ishan
  7. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 posts

    Posted 21 Oct 2013 Link to this post

    Hello Ishan,

    I can not be sure about your current implementation, this is why I need to check a few things before making any suggestion. Is it possible for you to check the following:
    • The property exposed by your ViewModel triggers the PropertyChanged event when it is changed. Please note that the Telerik's ViewModelBase class implements the INotifyPropertyChanged interface and you can derive your custom ViewModel from our class and use the OnPropertyChanged() method.
    • The binding between the two properties is TwoWay
    • The GraphSource is observable or serializable

    Basically if all of these requirements are implemented the position property exposed by your ViewModel should be updated by the UI of your application (or vise versa). In case that these points are implemented but you still are not able to update the Position property, I will need to take a look at your current implementation in order to make a proper suggestion.

    Thank you for understanding.


    Regards,
    Pavel R. Pavlov
    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 >>
Back to Top
UI for WPF is Visual Studio 2017 Ready