public CanvasHolder(Canvas canvas) { var canvasDrawables = canvas.Drawbles; translation = canvas.Translation; List <NodeHolder> nodeHoldersList = new List <NodeHolder>(); List <NodeRingHolder> nodeRingHoldersList = new List <NodeRingHolder>(); List <WireHolder> wireHoldersList = new List <WireHolder>(); IDGenerator idGenerator = new IDGenerator(); foreach (Drawable d in canvasDrawables) { if (d.GetType() == typeof(Node)) { Node node = (Node)d; ID nodeId = idGenerator.Add(node); List <Drawable> nodeElements = node.Elements; int[] nodeHolderElements = new int[nodeElements.Count]; for (int i = 0; i < nodeElements.Count; i++) { NodeRing nodeRing = (NodeRing)nodeElements[i]; ID nodeRingId = idGenerator.Add(nodeRing); nodeHolderElements[i] = nodeRingId.value; nodeRingHoldersList.Add(new NodeRingHolder(nodeRingId.value, nodeId.value, nodeRing.Title, nodeRing.Color, nodeRing.Direction)); } nodeHoldersList.Add(new NodeHolder(nodeId.value, node.BoundingBox.X, node.BoundingBox.Y, node.BoundingBox.Width, node.Title, nodeHolderElements)); } } foreach (Drawable d in canvasDrawables) { if (d.GetType() == typeof(Wire)) { Wire wire = (Wire)d; ID wireId = idGenerator.Add(wire); wireHoldersList.Add(new WireHolder(wireId.value, idGenerator.Find(wire.Start.Drawable).value, idGenerator.Find(wire.End.Drawable).value)); } } nodeHolders = nodeHoldersList.ToArray(); nodeRingHolders = nodeRingHoldersList.ToArray(); wireHolders = wireHoldersList.ToArray(); }