Hi,
I am able to draw a shape with an outline and text but no fill as follows:
new DiagramNode(){
Name = "SAMPLE"; Fill = new SolidColorBrush(Colors.Aqua) {Opacity = 0}; Stroke = Brushes.HotPink; StrokeThickness = 1; NodeType = NodeType.Circle; Height = 60; Width = 60; Content = "Sample"; Position = new Point(50, 50); FontBrush = Brushes.DarkGreen; }
This works fine (draws as expected). However when I try to serialize and then deserialize it using the following code:
public void SerializeToXml() { using (var stream = PersistenceManager.Save(Diagram)) { using (var fileStream = new FileStream(@"C:\test.xml", FileMode.Create)) { fileStream.Write(stream.ToArray(), 0, (int)stream.Length); } } }
public void DeserializeFromXml() { using (var fileStream = new FileStream(@"C:\test.xml", FileMode.OpenOrCreate)) { PersistenceManager.Load(Diagram, fileStream); } }
the shape comes back filled Green rather than clear.
How can I create a clear DiagramNode that will serialize and deserialize correctly?
Regards
David
Hello David,
Instead of setting the Opacity property of the Brush used for the node's Fill, use a transparent brush:
...
Fill = Brushes.Transparent;
This produces the desired result.
Regards,
Philip