コード例 #1
0
 public bool ReplaceComponent(string Component, decimal value, decimal flow, Component replace, Point p)
 {
     if (!CanPlaceItem(p))
     {
         removeOnlyComponent(replace);
         if (Component == "Sink")
         {
             replace = new Sink(p);
         }
         else if (Component == "Merger")
         {
             replace = new Merger(p);
         }
         else if (Component == "Splitter")
         {
             replace = new Splitter(p, Convert.ToInt32(value));
         }
         else if (Component == "Pump")
         {
             if (replace is Pump)
             {
                 replace = new Pump(p, value, flow);
             }
         }
         if (DrawItemsEvent != null && replace != null)
         {
             replace.direction = "East";
             items.Add(replace);
             DrawItemsEvent();
             return(true);
         }
         return(false);
     }
     else
     {
         return(false);
     }
 }
コード例 #2
0
        private bool addComponent(string Component, Point pos, decimal value, decimal flow)
        {
            Component c = null;

            if (CanPlaceItem(pos))
            {
                if (Component == "Sink")
                {
                    c = new Sink(pos);
                }
                else if (Component == "Merger")
                {
                    c = new Merger(pos);
                }
                else if (Component == "Splitter")
                {
                    c = new Splitter(pos, Convert.ToInt32(value));
                }
                else if (Component == "Pump")
                {
                    c = new Pump(pos, value, flow);
                }
                if (DrawItemsEvent != null && c != null)
                {
                    c.direction = "East";
                    items.Add(c);
                    DrawItemsEvent();
                    return(true);
                }
                return(false);
            }
            else
            {
                return(false);
            }
        }