Esempio n. 1
0
    protected bool Append(WiringCollectionBase otherDoc)
    {
        bool any = false;

        foreach (WiringDocument doc in otherDoc.Documents)
        {
            if (this.AddDocument(doc) == true)
            {
                any = true;
            }
        }

        return(any);
    }
Esempio n. 2
0
    public bool LoadXML(System.Xml.XmlElement ele)
    {
        if (ele.Name != "wiring")
        {
            return(false);
        }

        System.Xml.XmlAttribute attrName = ele.Attributes["name"];
        if (attrName != null)
        {
            this.name = attrName.Value;

            if (this.name.Length > MaxNameLen)
            {
                this.name = this.name.Substring(0, MaxNameLen);
            }
        }

        System.Xml.XmlAttribute attrCat = ele.Attributes["cat"];
        if (attrCat != null)
        {
            this.category = WiringCollectionBase.GetCategoryFromName(attrCat.Value);
        }

        Dictionary <string, LLDNBase> directory =
            new Dictionary <string, LLDNBase>();

        Dictionary <LLDNBase, System.Xml.XmlElement> xmlToGNMap =
            new Dictionary <LLDNBase, System.Xml.XmlElement>();

        foreach (System.Xml.XmlElement eleNode in ele)
        {
            if (eleNode.Name != "node")
            {
                continue;
            }

            System.Xml.XmlAttribute attrType = eleNode.Attributes["type"];
            if (attrType == null)
            {
                continue;
            }

            LLDNBase.NodeType nt;
            if (System.Enum.TryParse <LLDNBase.NodeType>(attrType.Value, true, out nt) == false)
            {
                continue;
            }


            string guid = null;
            System.Xml.XmlAttribute attrID = eleNode.Attributes["id"];
            if (attrID != null)
            {
                guid = attrID.Value;
            }

            LLDNBase newGN = LLDNBase.CreateGenerator(nt, guid);
            if (newGN.LoadXML(eleNode) == false)
            {
                continue;
            }

            System.Xml.XmlAttribute attrX = eleNode.Attributes["x"];
            if (attrX != null)
            {
                float.TryParse(attrX.Value, out newGN.cachedUILocation.x);
            }

            System.Xml.XmlAttribute attrY = eleNode.Attributes["y"];
            if (attrY != null)
            {
                float.TryParse(attrY.Value, out newGN.cachedUILocation.y);
            }

            this.generators.Add(newGN);
            xmlToGNMap.Add(newGN, eleNode);
            directory.Add(newGN.GUID, newGN);
        }

        foreach (LLDNBase gnb in this.generators)
        {
            gnb.LoadXML(xmlToGNMap[gnb], directory);
        }

        string outputID = null;

        System.Xml.XmlAttribute attrOutput = ele.Attributes["output"];
        if (attrOutput != null)
        {
            outputID = attrOutput.Value;
        }

        if (string.IsNullOrEmpty(outputID) == false)
        {
            LLDNBase gnbOut;
            if (directory.TryGetValue(outputID, out gnbOut) == true)
            {
                this.output = gnbOut as LLDNOutput;
            }
        }

        return(true);
    }
Esempio n. 3
0
 public string GetCategoryName()
 {
     return(WiringCollectionBase.GetCategoryName(this.category));
 }