Example #1
0
        /// <summary>
        /// The post load operation
        /// </summary>
        public override bool PostLoad()
        {
            //return base.PostLoad();
            if (!isLoaded)
            {
                return(false);
            }
            if (isPostLoaded)
            {
                return(true);
            }
            desktop.SetObjectNames();
            PureObjectLabel.SetLabels(desktop.Objects);
            PureArrowLabel.SetLabels(desktop.Arrows);
            IEnumerable <IArrowLabel> arrows = desktop.Arrows;
//            SetParents(desktop);
            IEnumerable <object> components = desktop.Components;

            foreach (INamedComponent nc in components)
            {
                nc.Desktop = desktop;
                //nc.Parent = Object as INamedComponent;
                if (nc is IObjectLabel)
                {
                    IObjectLabel ol = nc as IObjectLabel;
                    if (ol.Object is IObjectContainer)
                    {
                        IObjectContainer oc = ol.Object as IObjectContainer;
                        bool             b  = oc.PostLoad();
                        if (!b)
                        {
                            return(false);
                        }
                    }
                }
            }
            foreach (IArrowLabel arrow in arrows)
            {
                arrow.Desktop = desktop;
                ICategoryObject source = arrow.Arrow.Source;
                if (source == null)
                {
                    arrow.Arrow.Source = arrow.Source.Object;
                }
                ICategoryObject target = arrow.Arrow.Target;
                if (target == null)
                {
                    arrow.Arrow.Target = arrow.Target.Object;
                }
                IAssociatedObject ass = arrow.Arrow as IAssociatedObject;
                ass.Object = arrow;
            }
            return(true);
        }
Example #2
0
        /// <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);
            }
        }
Example #3
0
 /// <summary>
 /// The post load operation
 /// </summary>
 /// <returns></returns>
 public bool PostLoad()
 {
     try
     {
         PureObjectLabel.SetLabels(this.Objects);
         PureArrowLabel.SetLabels(this.Arrows);
         this.SetParents();
         IEnumerable <object> components = Components;
         foreach (INamedComponent nc in components)
         {
             nc.Desktop     = this;
             table[nc.Name] = nc;
             if (nc is IObjectLabel)
             {
                 IObjectLabel ol = nc as IObjectLabel;
                 if (ol.Object is IObjectContainer)
                 {
                     IObjectContainer oc = ol.Object as IObjectContainer;
                     bool             b  = oc.PostLoad();
                     if (!b)
                     {
                         return(false);
                     }
                 }
             }
         }
         foreach (IArrowLabel arrow in arrows)
         {
             IObjectLabel source = null;
             IObjectLabel target = null;
             if (arrow.SourceNumber is Int32)
             {
                 source = objects[(int)arrow.SourceNumber] as IObjectLabel;
             }
             else
             {
                 object[]         os = arrow.SourceNumber as object[];
                 IObjectLabel     so = objects[(int)os[0]] as IObjectLabel;
                 IObjectContainer sc = so.Object as IObjectContainer;
                 source = sc[os[1] as string] as IObjectLabel;
             }
             if (arrow.TargetNumber is Int32)
             {
                 target = objects[(int)arrow.TargetNumber] as IObjectLabel;
             }
             else
             {
                 object[]         ot = arrow.TargetNumber as object[];
                 IObjectLabel     to = objects[(int)ot[0]] as IObjectLabel;
                 IObjectContainer tc = to.Object as IObjectContainer;
                 target = tc[ot[1] as string] as IObjectLabel;
             }
             arrow.Arrow.Source = source.Object;
             arrow.Arrow.Target = target.Object;
             arrow.Source       = source;
             arrow.Target       = target;
             IAssociatedObject ass = arrow.Arrow as IAssociatedObject;
             ass.Object = arrow;
         }
         return(true);
     }
     catch (Exception ex)
     {
         ex.ShowError(10);
         if (exceptions != null)
         {
             exceptions.Add(ex);
         }
     }
     return(false);
 }
Example #4
0
 /// <summary>
 /// Copies objects and arrows
 /// </summary>
 /// <param name="objects">Objects</param>
 /// <param name="arrows">Arrows</param>
 /// <param name="associated">Copy associated objects sign</param>
 public override void Copy(IEnumerable <IObjectLabel> objects, IEnumerable <IArrowLabel> arrows, bool associated)
 {
     foreach (IObjectLabel l in objects)
     {
         string type = l.Type;
         string st   = l.Object.GetType() + "";
         if (!type.Equals(st))
         {
             //type = st;
         }
         PureObjectLabelPeer lp = new PureObjectLabelPeer(l.Name, l.Kind, type, l.X, l.Y);
         Type     t             = l.GetType();
         object[] o             = t.GetCustomAttributes(typeof(SerializableLabelAttribute), true);
         if (o != null)
         {
             if (o.Length > 0)
             {
                 IObjectLabelHolder lh = lp;
                 lh.Label = l;
             }
         }
         IObjectLabel lab = lp;
         lab.Object  = l.Object;
         lab.Desktop = this;
         this.objects.Add(lab);
         if (associated)
         {
             lab.Object.Object = lab;
         }
         table[l.Name] = lab;
     }
     //PureObjectLabel.Wrappers = false;
     foreach (IArrowLabel l in arrows)
     {
         PureArrowLabelPeer lp = new PureArrowLabelPeer(l.Name, l.Kind, l.Type, l.X, l.Y);
         Type     t            = l.GetType();
         object[] o            = t.GetCustomAttributes(typeof(SerializableLabelAttribute), true);
         if (o != null)
         {
             if (o.Length > 0)
             {
                 IArrowLabelHolder lh = lp;
                 lh.Label = l;
             }
         }
         IArrowLabel lab = new PureArrowLabelPeer(l.Name, l.Kind, l.Type, l.X, l.Y);
         lab.Arrow = l.Arrow;
         if (associated)
         {
             lab.Arrow.Object = lab;
         }
         lab.Desktop = this;
         this.arrows.Add(lab);
         // components.Add(lab);
         table[l.Name] = lab;
         List <IObjectLabel> objs  = objects.ToList <IObjectLabel>();
         List <IObjectLabel> tobjs = this.Objects.ToList <IObjectLabel>();
         lab.Source = PureDesktop.Find(objs, tobjs, l.Source, l.Desktop);
         lab.Target = PureDesktop.Find(objs, tobjs, l.Target, l.Desktop);
     }
     if (!associated)
     {
         return;
     }
     this.SetParents();
     PureObjectLabel.SetLabels(objects);
     PureArrowLabel.SetLabels(arrows);
 }