/* (non-Dotnetdoc) * see com.mxgraph.mxICell.Clone() */ public Object Clone() { mxCell cell = new mxCell(); cell.Collapsed = Collapsed; cell.Connectable = Connectable; cell.Edge = Edge; cell.Style = Style; cell.Vertex = Vertex; cell.Visible = Visible; mxGeometry geometry = Geometry; if (geometry != null) { cell.Geometry = geometry.Clone(); } Object value = Value; if (value is XmlNode) { cell.Value = ((XmlNode)value).CloneNode(true); } else { cell.Value = Value; } return(cell); }
/// <summary> /// Creates a new root cell with a default layer (child 0). /// </summary> public Object CreateRoot() { mxCell root = new mxCell(); root.Insert(new mxCell()); return(root); }
/// <summary> /// Clones the children of the source cell into the given target cell in /// this model and adds an entry to the mapping that maps from the source /// cell to the target cell with the same id or the clone of the source cell /// that was inserted into this model. /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="cloneAllEdges"></param> /// <param name="mapping"></param> protected void MergeChildrenImpl(mxICell from, mxICell to, bool cloneAllEdges, Dictionary <Object, Object> mapping) { BeginUpdate(); try { int childCount = from.ChildCount(); for (int i = 0; i < childCount; i++) { mxICell cell = from.GetChildAt(i); String id = cell.Id; mxICell target = (mxICell)((id != null && (!IsEdge(cell) || !cloneAllEdges)) ? GetCell(id) : null); // Clones and adds the child if no cell exists for the id if (target == null) { mxCell clone = (mxCell)cell.Clone(); clone.Id = id; // Do *NOT* use model.add as this will move the edge away // from the parent in updateEdgeParent if maintainEdgeParent // is enabled in the target model target = to.Insert(clone); CellAdded(target); } // Stores the mapping for later reconnecting edges mapping[cell] = target; // Recurses MergeChildrenImpl(cell, target, cloneAllEdges, mapping); } } finally { EndUpdate(); } }