/// <summary> /// Deserialize Node /// </summary> /// <param name="shape"></param> /// <param name="info"></param> /// <returns></returns> public override NodeViewModelBase DeserializeNode(IShape shape, SerializationInfo info) { NodeViewModelBase node = null; if (shape is IContainerShape) { node = new ContainerNodeViewModelBase <NodeViewModelBase>(); } else { node = new NodeViewModelBase(); } if (info["Content"] != null) { node.Content = info["Content"].ToString(); } if (info["NodePosition"] != null) { var position = Utils.ToPoint(info["NodePosition"].ToString()); if (position.HasValue) { node.Position = position.Value; } } if (info[this.NodeUniqueIdKey] != null) { var nodeUniquekey = info[this.NodeUniqueIdKey].ToString(); this.CachedNodes[nodeUniquekey] = node; } return(node); }
public DiagramGraphSource() { var first = new NodeViewModelBase() { Position = new Point(200, 200), Content = "First item", Height = 60, Width = 80 }; var second = new NodeViewModelBase() { Position = new Point(600, 200), Content = "Second item", Height = 60, Width = 80 }; var third = new ContainerNodeViewModelBase <NodeViewModelBase> { Position = new Point(800, 200), Content = "Third item", }; var connection = new StartEndLink() { StartPointVM = new Point(300, 225), EndPointVM = new Point(550, 225) }; AddNode(first); AddNode(second); AddNode(third); AddLink(connection); }