/// <summary> /// Copies objects and arrows /// </summary> /// <param name="objects">Objects</param> /// <param name="arrows">Arrows</param> /// <param name="associated">Sign for setting associated objects</param> public virtual void Copy(IEnumerable <IObjectLabel> objects, IEnumerable <IArrowLabel> arrows, bool associated) { List <IObjectLabel> objs = new List <IObjectLabel>(); List <IObjectLabel> tobjs = new List <IObjectLabel>(); foreach (IObjectLabel l in objects) { objs.Add(l); IObjectLabel lab = new PureObjectLabel(l.Name, l.Kind, l.Type, l.X, l.Y); tobjs.Add(lab); lab.Object = l.Object; lab.Desktop = this; this.objects.Add(lab); if (l.Object is IObjectContainer) { IObjectContainer oc = l.Object as IObjectContainer; oc.SetParents(this); oc.Load(); } // components.Add(lab); table[l.Name] = lab; } List <IArrowLabel> arrs = new List <IArrowLabel>(); foreach (IArrowLabel l in arrows) { IArrowLabel lab = new PureArrowLabel(l.Name, l.Kind, l.Type, l.X, l.Y); lab.Arrow = l.Arrow; lab.Desktop = this; arrs.Add(lab); table[l.Name] = lab; IObjectLabel source = Find(objs, tobjs, l.Source, l.Desktop); IObjectLabel target = Find(objs, tobjs, l.Target, l.Desktop); lab.Source = source; lab.Target = target; } if (!associated) { return; } this.SetParents(); PureObjectLabel.SetLabels(objects); PureArrowLabel.SetLabels(arrs); foreach (IArrowLabel l in arrs) { this.arrows.Add(l); } }
/// <summary> /// Expands children /// </summary> public void Expand() { IObjectContainer cont = Object as IObjectContainer; cont.Load(); cont.PostLoad(); if (cont is ICategoryObject) { ICategoryObject ca = cont as ICategoryObject; ca.Object = this; } Dictionary <string, object> table = cont.Interface; foreach (string name in table.Keys) { INamedComponent c = cont[name]; object[] o = table[name] as object[]; ChildObjectLabel l = new ChildObjectLabel(this, name, c, o); inter.Add(l); ContainerPerformer.Children[c as IObjectLabel] = l; } }
private bool load(Stream stream, SerializationBinder binder, bool post) { stream.Position = 0; BinaryFormatter bformatter = new BinaryFormatter(); if (binder != null) { bformatter.Binder = binder; } try { objects = new List <IObjectLabel>(); arrows = new List <IArrowLabel>(); ArrayList objs = bformatter.Deserialize(stream) as ArrayList; ArrayList arrs = bformatter.Deserialize(stream) as ArrayList; if (objs != null) { objects = new List <IObjectLabel>(); foreach (IObjectLabel l in objs) { objects.Add(l); } } if (arrs != null) { arrows = new List <IArrowLabel>(); foreach (IArrowLabel l in arrs) { arrows.Add(l); } } foreach (object o in objects) { if (o is INamedComponent) { INamedComponent nc = o as INamedComponent; nc.Desktop = this; string n = nc.Name; if (!table.ContainsKey(n)) { table[n] = nc; } } if (o is IObjectLabel) { IObjectLabel l = o as IObjectLabel; object os = l.Object; if (os is IAssociatedObject) { IAssociatedObject ass = os as IAssociatedObject; ass.Object = l; PostSetObject(ass); } if (os is IObjectContainer) { IObjectContainer oc = os as IObjectContainer; bool lb = oc.Load(); if (!lb) { return(false); } } } } foreach (object o in arrows) { if (o is INamedComponent) { if (o is IArrowLabel) { IArrowLabel l = o as IArrowLabel; object os = l.Arrow; if (os is IAssociatedObject) { IAssociatedObject ass = os as IAssociatedObject; ass.Object = l; PostSetObject(ass); } } INamedComponent nc = o as INamedComponent; string n = nc.Name; if (!table.ContainsKey(n)) { table[n] = nc; } nc.Desktop = this; } } if (post) { bool b = PostLoad(); if (!b) { return(false); } return(PostDeserialize()); } return(true); } catch (Exception ex) { ex.ShowError(10); if (exceptions != null) { exceptions.Add(ex); } } return(false); }