Hi JR,
ControlNodes add just one property (Control) to what they derive from DiagramNode, so there isn't much documentation specific to them.
The Demo example uses ControlNodes in the Network diagram step, and you can find some sample deserialization code there. I've also found some serialization code in our test application:
private void diagram_SerializeControl(object sender, ControlNodeEventArgs e)
{
e.Handled = true;
if (e.Node is ControlNode)
{
ControlNode ctNd = e.Node as ControlNode;
if (ctNd.Control is TextBox)
{
TextBox tb = ctNd.Control as TextBox;
e.Context.WriteString("TextBox", "ControlType", e.XmlElement);
e.Context.WriteString(tb.Text, "Value", e.XmlElement);
}
else if (ctNd.Control is Button)
{
Button btn = ctNd.Control as Button;
e.Context.WriteString("Button", "ControlType", e.XmlElement);
e.Context.WriteString(btn.Content.ToString(), "Value", e.XmlElement);
}
}
}
private void diagram_DeserializeControl(object sender, ControlNodeEventArgs e)
{
e.Handled = true;
string str = e.Context.ReadString("ControlType", e.XmlElement);
string value = e.Context.ReadString("Value", e.XmlElement);
if ("TextBox".Equals(str))
{
TextBox tb = new TextBox();
tb.Text = value;
(e.Node as ControlNode).Control = tb;
}
else if ("Button".Equals(str))
{
Button btn = new Button();
btn.Content = value;
(e.Node as ControlNode).Control = btn;
}
}
You can use the LINQ for XML API to save and load custom data, or use the helper e.Context methods as shown above.
If you are going to use only a few types of controls, you might create classes derived from ControlNode for each specific user control and override SaveToXml and LoadFromXml to serialize the custom data, rather than implementing the serialization code for all controls in a single event handler.
I hope that helps,
Stoyan