示例#1
0
 public void PreSave()
 {
     this.SetParents();
     PureObjectLabel.SetType(objects);
     PureArrowLabel.SetType(arrows);
     foreach (IArrowLabel label in arrows)
     {
         if (objects.Contains(label.Source))
         {
             label.SourceNumber = objects.IndexOf(label.Source);
         }
         else
         {
             IObjectLabel     ls    = label.Source.GetRoot(this) as IObjectLabel;
             int              sn    = objects.IndexOf(ls);
             IObjectContainer scont = ls.Object as IObjectContainer;
             string           ns    = scont.GetName(label.Source);
             label.SourceNumber = new object[] { sn, ns };
         }
         if (objects.Contains(label.Target))
         {
             label.TargetNumber = objects.IndexOf(label.Target);
         }
         else
         {
             IObjectLabel     lt    = label.Target.GetRoot(this) as IObjectLabel;
             int              tn    = objects.IndexOf(lt);
             IObjectContainer tcont = lt.Object as IObjectContainer;
             string           nt    = tcont.GetName(label.Target);
             label.TargetNumber = new object[] { tn, nt };
         }
     }
 }
示例#2
0
        /// <summary>
        /// Finds object from array
        /// </summary>
        /// <param name="source">Source labels</param>
        /// <param name="target">Target labels</param>
        /// <param name="label">Prototype label</param>
        /// <param name="desktop">The desktop</param>
        /// <returns>Found object</returns>
        /// <summary>
        /// Finds object from array
        /// </summary>
        /// <param name="source">Source labels</param>
        /// <param name="target">Target labels</param>
        /// <param name="label">Prototype label</param>
        /// <param name="desktop">The desktop</param>
        /// <returns>Found object</returns>
        static public IObjectLabel Find(IList <IObjectLabel> source, IList <IObjectLabel> target, IObjectLabel label, IDesktop desktop)
        {
            if (source.Contains(label))
            {
                int n = source.IndexOf(label);
                return(target[n] as IObjectLabel);
            }
            IObjectLabel     ol  = label.GetRoot(desktop) as IObjectLabel;
            int              nt  = source.IndexOf(ol);
            IObjectContainer oct = ol.Object as IObjectContainer;
            string           tn  = oct.GetName(label);
            IObjectLabel     ot  = target[nt] as IObjectLabel;
            IObjectContainer ct  = ot.Object as IObjectContainer;

            return(ct[tn] as IObjectLabel);
        }