/// <summary> /// Inserts the given cell into its parent and terminal cells. /// </summary> /// <param name="cell"></param> public void InsertIntoGraph(mxICell cell) { mxICell parent = cell.Parent; mxICell source = cell.GetTerminal(true); mxICell target = cell.GetTerminal(false); // Fixes possible inconsistencies during insert into graph cell.SetTerminal(null, false); cell.SetTerminal(null, true); cell.Parent = null; if (parent != null) { parent.Insert(cell); } if (source != null) { source.InsertEdge(cell, true); } if (target != null) { target.InsertEdge(cell, false); } }
/// <summary> /// Inner helper method for restoring the connections in /// a network of cloned cells. /// </summary> protected void RestoreClone(Object clone, Object cell, Hashtable mapping) { if (clone is mxICell) { mxICell mxc = (mxICell)clone; Object source = GetTerminal(cell, true); if (source is mxICell) { mxICell tmp = (mxICell)mapping[source]; if (tmp != null) { tmp.InsertEdge(mxc, true); } } Object target = GetTerminal(cell, false); if (target is mxICell) { mxICell tmp = (mxICell)mapping[target]; if (tmp != null) { tmp.InsertEdge(mxc, false); } } } int childCount = GetChildCount(clone); for (int i = 0; i < childCount; i++) { RestoreClone(GetChildAt(clone, i), GetChildAt(cell, i), mapping); } }