Esempio n. 1
0
        /// <summary>
        /// Adds arrow with existing source and target
        /// </summary>
        /// <param name="arrow">Arrow</param>
        /// <param name="source">Source</param>
        /// <param name="target">Target</param>
        /// <param name="name">Arrow name</param>
        /// <param name="kind">Arrow kind</param>
        /// <returns>Added arrow</returns>
        public IArrowLabel AddArrowWithExistingLabels(ICategoryArrow arrow,
                                                      IObjectLabel source, IObjectLabel target, string name, string kind)
        {
            source.Object.Object = source;
            target.Object.Object = target;
            IArrowLabel arrowLabel = new PureArrowLabelPeer(name, kind, arrow.GetType().FullName, 0, 0);

            arrowLabel.Desktop = this;
            arrowLabel.Arrow   = arrow;
            arrow.Object       = arrowLabel;
            arrowLabel.Source  = source;
            arrowLabel.Target  = target;
            arrowLabel.Arrow   = arrow;
            arrow.Source       = source.Object;
            arrow.Target       = target.Object;
            arrows.Add(arrowLabel);
            return(arrowLabel);
        }
Esempio n. 2
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);
 }