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

Cut/Copy/Paste with GraphSource

5 Answers 196 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 27 Sep 2013, 09:14 PM
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

5 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 02 Oct 2013, 02:05 PM
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 >>
0
Steve
Top achievements
Rank 1
answered on 02 Oct 2013, 02:20 PM
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
0
Pavel R. Pavlov
Telerik team
answered on 07 Oct 2013, 08:21 AM
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 >>
0
Ishan
Top achievements
Rank 1
answered on 16 Oct 2013, 12:29 PM
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
0
Pavel R. Pavlov
Telerik team
answered on 21 Oct 2013, 11:50 AM
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 >>
Tags
Diagram
Asked by
Steve
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Steve
Top achievements
Rank 1
Ishan
Top achievements
Rank 1
Share this question
or