We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

SfDiagram serialisation of Annotations and ShapeStyle

Thread ID:

Created:

Updated:

Platform:

Replies:

128983 Feb 20,2017 05:42 AM Feb 23,2017 07:50 AM UWP 3
loading
Tags: SfDiagram
PH
Asked On February 20, 2017 05:42 AM

Hi

I am trying to serialise diagrams containing nodes of the NodeViewModel type, however it seems like some information is lost during serialisation. The missing properties that are the most important to me are Annotations and ShapeStyle are either empty or null XML elements (I attach an example of the serialised XML). In the documentation for SfDiagram serialisation it says that all standard properties should be handled by default (https://help.syncfusion.com/uwp/sfdiagram/serialization), but it does not seem to work for me. Is there anything else I need to do in order to serialise these properties?

Thanks,

Piotr

Attachment: serialised_diagram.xml_2d9112fa.zip

Suresh Shanmugam [Syncfusion]
Replied On February 22, 2017 07:08 AM

Hi Piotr, 

Requirement : “Need to Serialize the Annotations and ShapeStyle” 
 
We have prepared the sample for this requirement in application level. Please find the sample as below location. 

Sample location : SfDiagram_Sample 
 
Sample Details: 
 
 
Annotations are getting serialized properly. We have set the newly created Style (custom Fill property in derived class of NodeViewModel) to the ShapeStyle after serialized for this sample.  
 
In this sample, click the button to save (Serialize) the diagram as xml file, then to load (deserialize) the xml file. 
 
Note : Xml file is save on Local state as below location  
 
Xml file location :  “\AppData\Local\Packages\d8f5d636-891c-4d27-8037-1038b17fe81b_ybrsvdyw61sem\LocalState” 
 
Now, ShapeStyle is loaded properly in the diagram page as expected. 
 
Regards,
Suresh Shanmugam
 


PH
Replied On February 22, 2017 09:33 AM

Hi Suresh,

Thanks for your response and the sample. It made me realise that I was breaking the NodeViewModel objects before serialisation as I was attempting to clone them and add them to another diagram (for scaling before saving). By cloning I mean creating a new object and assigning the properties of the original to it (since there is no Clone method available). Is there a better way of creating a clone programatically?

Also, judging from your sample I would have to create a custom property for each of the style properties, like Stroke, StrokeThickness etc. Is there no way to serialise ShapeStyle itself?

For a custom object extending AnnotationEditorViewModel that stores font size, colour and background colour would I also need to store all the properties like the Fill property in the sample?

Regards,

Piotr

Suresh Shanmugam [Syncfusion]
Replied On February 23, 2017 07:50 AM

Hi Piotr, 
 
Please find the responses for your queries as below, 
 
Query 
Response 
 I was attempting to clone them and add them to another diagram (for scaling before saving). 
Is there a better way of creating a clone programatically? 
 
We have a support to Clone the Elements by using Copy/Paste Command. Please find the code snippet as below. 
 
Code Snippet: 
 
IGraphInfo graphinfo = diagramcontrol.Info as IGraphInfo;  
 
//Copies the selected elements from the Diagram to the Diagram’s clipboard. 
graphinfo.Commands.Copy.Execute(null);  
 
//Pastes the Diagram’s clipboard data (nodes/connectors) into the Diagram. 
graphinfo.Commands.Paste.Execute(null); 
 
 
Is there any way to serialize ShapeStyle itself? 
 
ShapeStyle have the Framework properties like Fill, Stroke. etc. We could not serialize the Framework properties. We need to create the custom properties for each of the style properties in specific Class (Nodevm). 
 
AnnotationEditorViewModel that stores font size, colour and background colour would I also need to store all the properties like the Fill property in the sample? 
 
We have prepared the sample based on this Query. Please find the sample location as below. 
 
Sample location : Annotation_ShapeStyle 
 
Sample Modification details: 
We have set the newly created DataTemplate (with custom FontSize and Foreground property like Fill property) to the ViewTemplate. 
 
 
 
Regards, 
Suresh Shanmugam 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;