Quote:I need specific properties stored within each object that are pulled from a database. The real challenge is: I must be able to save to a memory stream (as a BLOB or XML storage inside the SQL Server). How can I do this using Mindfusion Diagram?
First consider storing just database records' ID in nodes' Id or Tag property. If you need all record values stored in node, you could create struct for them -
[Serializable]
class ExtraProps
{
public string Prop1 { get; set; };
public int Props2 { get; set; };
...
}
and assign its instances to Tag or Id properties. That's shown e.g. in SiteMap sample project. Tag/Id struct is serialized automatically in binary format. If you need it saved in XML, you will need to handle Diagram.SerializeTag event handler.
Otherwise if you need your properties directly in node class, then you can follow approach from IconNodes example -
public class IconNode : DiagramNode
{
protected override void SaveTo(System.IO.BinaryWriter writer, PersistContext ctx)
{
base.SaveTo(writer, ctx);
// Save the label using the standard .NET BinaryWriter
writer.Write(label);
// Save the image using the MindFusion.Diagramming built-in image saving code,
// which stores the contents of shared images only once.
ctx.SaveImage(icon);
}
protected override void LoadFrom(System.IO.BinaryReader reader, PersistContext ctx)
{
base.LoadFrom(reader, ctx);
label = reader.ReadString();
icon = ctx.LoadImage();
}
Image icon;
string label;
}
// Enable serialization of IconNode instances
Diagram.RegisterItemClass(typeof(IconNode), "IconNode", 100);