Hi,
I try to add custom object to NodeViewModel and serialize this custom object with the node by node serialize function.
But I still can't find my custom object in serialize XML file.
My custom object:
public class POS_Contract : INotifyPropertyChanged
{
public POS_Contract()
{
Nodettla = "ggla";
}
[DataMember]
public string Nodettla
{
get;
set;
}
public event PropertyChangedEventHandler PropertyChanged;
}
=======================
and my node add function:
public void addPosNode(double OffsetX, double OffsetY)
{
sf_diagram.KnownTypes = () => new List<Type>()
{
typeof(POS_Contract)
};
POS_Contract pc = new POS_Contract();
NodeViewModel node = new NodeViewModel()
{
Content = pc,
ID = "node_pos_" + Guid.NewGuid(),
Constraints = NodeConstraints.Default & ~NodeConstraints.Resizable & ~NodeConstraints.Rotatable,
OffsetX = OffsetX,
OffsetY = OffsetY,
Pivot = new Point(0, 0),
UnitWidth = 120,
UnitHeight = 40,
Shape = App.Current.Resources["Process"],
//Add node shape style
ShapeStyle = stylePosNode.styleNode,
Annotations = new ObservableCollection<AnnotationEditorViewModel>()
{
new AnnotationEditorViewModel()
{
Content="POS",
}
},
Ports = new ObservableCollection<NodePortViewModel>()
{
new NodePortViewModel()
{
ID = "POS_IN",
Constraints = PortConstraints.Default & ~PortConstraints.InheritPortVisibility,
PortVisibility = PortVisibility.Visible,
NodeOffsetX = 0.5 ,
NodeOffsetY = 0,
ShapeStyle = stylePosNode.styleInPort,
Shape = new EllipseGeometry() { RadiusX= 5, RadiusY = 5 },
},
new NodePortViewModel()
{
ID = "POS_OUT",
Constraints = PortConstraints.Default & ~PortConstraints.InheritPortVisibility,
PortVisibility = PortVisibility.Visible,
NodeOffsetX = 0.5 ,
NodeOffsetY = 1,
ShapeStyle = stylePosNode.styleInPort,
Shape = new EllipseGeometry() { RadiusX= 5, RadiusY = 5 },
}
}
};
nodes.Add(node);
sf_diagram.Nodes = nodes;
}
======================
Thanks!