/// <summary>
 /// Zwraca in¿yniera odpowiedzialnego za maszynê lub narzêdzie
 /// reprezentowany przez dany obiekt.
 /// </summary>
 /// <param name="item">sprawdzany obiekt</param>
 /// <returns>in¿ynier odpowiedzialny</returns>
 public Engineer GetResponsible(VisualizationItem item)
 {
     if (item is Tool)
     {
         Tool t = (Tool)item;
         return(t.ToolCart.Responsible);
     }
     if (item is ToolCart)
     {
         ToolCart tc = (ToolCart)item;
         return(tc.Responsible);
     }
     if (item is MachineComponent)
     {
         MachineComponent c = (MachineComponent)item;
         if (c.Responsible != null)
         {
             return(c.Responsible);
         }
         if (c.Parent != null)
         {
             return(c.Parent.Responsible);
         }
     }
     return(null);
 }
Esempio n. 2
0
        /// <summary>
        /// Return true if, according to business rules, this
        /// component and the supplied object refer to the same
        /// thing.
        /// </summary>
        /// <param name="o">The candidate to compare to</param>
        /// <returns>true, if this object and the supplied object represent
        /// the same machine</returns>
        public override bool Equals(Object o)
        {
            if (o == this)
            {
                return(true);
            }
            if (!(o is MachineComponent))
            {
                return(false);
            }
            MachineComponent mc = (MachineComponent)o;

            return(_id == mc.ID);
        }
 /// <summary>
 /// Zwraca komponent w grafie maszyn, którego nazwa odpowiada podanej.
 /// </summary>
 /// <param name="id">szukana nazwa</param>
 /// <returns>komponent w grafie maszyn, którego nazwa odpowiada podanej</returns>
 public override MachineComponent Find(String name)
 {
     if (name.Equals(ToString()))
     {
         return(this);
     }
     foreach (MachineComponent child in _components)
     {
         MachineComponent mc = child.Find(name);
         if (mc != null)
         {
             return(mc);
         }
     }
     return(null);
 }
 /// <summary>
 /// Zwraca komponent w grafie maszyn, którego identyfikator
 /// odpowiada podanemu.
 /// </summary>
 /// <param name="id">szukany identyfikator</param>
 /// <returns>komponent w grafie maszyn, którego identyfikator odpowiada podanemu</returns>
 public override MachineComponent Find(int id)
 {
     if (_id == id)
     {
         return(this);
     }
     foreach (MachineComponent child in _components)
     {
         MachineComponent mc = child.Find(id);
         if (mc != null)
         {
             return(mc);
         }
     }
     return(null);
 }
 /// <summary>
 /// Dodaje podany komponent jako potomka.
 /// </summary>
 /// <param name="component">dodawany komponent</param>
 public void Add(MachineComponent component)
 {
     _components.Add(component);
 }