Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to skip the styles serialization? (Read 2120 times)
bogdip
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 70
Joined: Sep 8th, 2008
How to skip the styles serialization?
Oct 30th, 2014 at 2:21pm
Print Post  
Hello,

We'd like the serialized diagram files not to include the diagram and diagram items styles. Is this possible to achieve?

The OnSerializeTag method is raised only for not-serializable properties so can't make use of it.

Thanks,
Bogdan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to skip the styles serialization?
Reply #1 - Oct 30th, 2014 at 3:19pm
Print Post  
Hi,

It's not possible to prevent style serialization; you could remove the style elements from XML after serialization instead:

Code
Select All
var xml = new XmlDocument();
diagram.SaveToXml(xml);

var nodeStyleElements = xml.SelectNodes(@"/Diagram/Nodes//Style");
foreach (XmlElement styleElement in nodeStyleElements)
	styleElement.ParentNode.RemoveChild(styleElement);

xml.Save(dlg.FileName);
 



Alternatively, try using a theme instead of individual styles if applying same styles to all items. Then you could temporarily set diagram.Theme = null before saving, and restoring it after that.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to skip the styles serialization?
Reply #2 - Nov 5th, 2014 at 9:19am
Print Post  
This version lets you skip styles by setting diagram.XmlOptions.SerializeStyles = false before calling SaveToXml or LoadFromXml methods:

https://mindfusion.eu/_beta/wpfdiag.3.2.zip

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
bogdip
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 70
Joined: Sep 8th, 2008
Re: How to skip the styles serialization?
Reply #3 - Nov 6th, 2014 at 1:29pm
Print Post  
It works fine, thanks!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint