Esempio n. 1
0
        /// <summary>
        /// Load a circuit group from a file.  All ICs in the file will be stored
        /// using the provided StoreIC method. The IC with no name will be returned
        /// as the primary circuit.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="sic"></param>
        /// <returns></returns>
        public UIGates.IC Load(string path, StoreIC sic)
        {
            XElement root = XElement.Load(path);

            // v1.0 and v1.1 did not mark version attribute, so check for null
            if (root.Attribute("Version") != null && root.Attribute("Version").Value != "1.2")
            {
                throw new Exception("Unsupport version " + root.Attribute("Version").Value);
            }

            UIGates.IC retic = null;
            foreach (XElement circuit in root.Elements())
            {
                if (circuit.Attribute("Name") != null)
                {
                    // check if we need to rename this circuit
                    try
                    {
                        icl.GetIC(circuit.Attribute("Name").Value);
                        // already has an IC by this name
                        UpdateICNames[circuit.Attribute("Name").Value] =
                            icl.GenerateAvailableName(circuit.Attribute("Name").Value);
                    }
                    catch (ArgumentException)
                    {
                        // not found, no problem
                    }
                }
                UIGates.IC ic = LoadCircuit(circuit);
                if (circuit.Attribute("Name") != null)
                {
                    sic(ic);
                }
                else
                {
                    retic = ic;
                }
            }

            return(retic);
        }
Esempio n. 2
0
        /// <summary>
        /// Load a circuit group from a file.  All ICs in the file will be stored
        /// using the provided StoreIC method. The IC with no name will be returned
        /// as the primary circuit.
        /// </summary>
        /// <param name="path"></param>
        /// <param name="sic"></param>
        /// <returns></returns>
        public UIGates.IC Load(string path, StoreIC sic)
        {
            XElement root = XElement.Load(path);
            // v1.0 and v1.1 did not mark version attribute, so check for null
            if (root.Attribute("Version") != null && root.Attribute("Version").Value != "1.2")
                throw new Exception("Unsupport version " + root.Attribute("Version").Value);

            UIGates.IC retic = null;
            foreach (XElement circuit in root.Elements()) 
            {
                if (circuit.Attribute("Name") != null)
                {
                    // check if we need to rename this circuit
                    try
                    {
                        icl.GetIC(circuit.Attribute("Name").Value);
                        // already has an IC by this name
                        UpdateICNames[circuit.Attribute("Name").Value] =
                            icl.GenerateAvailableName(circuit.Attribute("Name").Value);
                    }
                    catch (ArgumentException)
                    {
                        // not found, no problem
                    }
                    
                }
                UIGates.IC ic = LoadCircuit(circuit);
                if (circuit.Attribute("Name") != null)
                    sic(ic);
                else
                    retic = ic;
            }

            return retic;
            
        }