/// <summary>
 /// Adds an item to the circuit and adds the step to the stack.
 /// </summary>
 /// <param name="item"></param>
 /// <returns>True if successful, false if not.</returns>
 public bool addItem(Item item)
 {
     Step step = new Step();
     Action action = new Action(circuit, Action.ActionType.add, item);
     
     step.addAction(action);
     if (step.execute())
     {
         addStep(step);
         return true;
     }
     else
     {
         return false;
     }
 }
        /// <summary>
        /// Deletes a connection and add a step to the stack 
        /// </summary>
        /// <param name="connection">The connection that will be deleted</param>
        /// <returns>True if succesful, false if not</returns>
        public bool deleteConnection(Connection connection)
        {
            Step step = new Step();
            Action action = new Action(circuit, Action.ActionType.delete, connection);

            step.addAction(action);
            if (step.execute())
            {
                addStep(step);
                return true;
            }
            else
            {
                return false;
            }

        }
        /// <summary>
        /// Changes source from 0 to 1 and vice versa.
        /// </summary>
        /// <param name="source"></param>
        public void toggle(IToggleable toggable)
        {
            Step step = new Step();
            Action action = new Action(circuit, Action.ActionType.toggle, toggable);

            step.addAction(action);
            step.execute();
            addStep(step);
        }
        /// <summary>
        ///  Deletes an item from the circuit and adds the step to the stack.
        /// </summary>
        /// <param name="item">The item that will be deleted</param>
        /// <returns> True if successful, false if not.</returns>
        public bool deleteItem(Item item)
        {
            Step step = new Step();

            List<Connection> associatedConnections = circuit.getAssociatedConnections(item);

            foreach (Connection associatedConnection in associatedConnections)
            {
                Action deleteAssociatedConnection = new Action(circuit, Action.ActionType.delete, associatedConnection);
                step.addAction(deleteAssociatedConnection);
            }

            Action action = new Action(circuit, Action.ActionType.delete, item);
            step.addAction(action);

            if (step.execute())
            {
                addStep(step);
                return true;
            }
            else
            {
                return false;
            }
        }