public object Clone(Subsystem s) { if (this.pnd != null) { SubsystemEditor se = new SubsystemEditor(this.pnd, s); Hashtable ht = new Hashtable(); for (int i = 0; i < this.pneEditor.Objects.Count; i++) { if (this.pneEditor.Objects[i] is ConnectableControl && this.pneEditor.Objects[i] is ICloneable) { ConnectableControl cc = (ConnectableControl)((ICloneable)this.pneEditor.Objects[i]).Clone(); ht.Add(this.pneEditor.Objects[i], cc); if (!(cc is Input) && !(cc is Output)) { cc.Index = this.pnd.InstanceCounter.GetAndIncreaseInstanceCount(cc); } else { cc.Index = ((ConnectableControl)this.pneEditor.Objects[i]).Index; } se.alDeserializedObjects.Add(cc); } else if (this.pneEditor.Objects[i] is DescriptionLabel && this.pneEditor.Objects[i] is ICloneable) { DescriptionLabel dl = (DescriptionLabel)((ICloneable)this.pneEditor.Objects[i]).Clone(); ht.Add(this.pneEditor.Objects[i], dl); dl.Index = ((DescriptionLabel)this.pneEditor.Objects[i]).Index; se.alDeserializedObjects.Add(dl); } } for (int i = 0; i < this.pneEditor.Connections.Count; i++) { Connection cn = (Connection)this.pneEditor.Connections[i]; cn = (Connection)cn.Clone((ConnectableControl)ht[cn.From], (ConnectableControl)ht[cn.To]); se.alDeserializedConnections.Add(cn); } foreach (object o in se.alDeserializedObjects) { if (o is Subsystem) { Subsystem ss = (Subsystem)o; ss.SuppresDeserializationCall(); } } se.RestoreControlsAndConnections(); foreach (object o in se.alDeserializedObjects) { if (o is Subsystem) { Subsystem ss = (Subsystem)o; ss.EnableDeserializationCall(); } } return(se); } return(null); }