public WiringDocument(bool createOutput, string guid) { if (string.IsNullOrEmpty(guid) == true) { this.guid = System.Guid.NewGuid().ToString(); } else { this.guid = guid; } if (createOutput == true) { this.output = new LLDNOutput(); this.output.cachedUILocation = new Vector2(300.0f, -50.0f); this.generators.Add(this.output); LLDNSineWave sine = new LLDNSineWave(); sine.cachedUILocation = new Vector2(30.0f, -30.0f); generators.Add(sine); this.output.SetConnection_Input(sine); } }
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); }
public void Clear() { this.output = null; this.generators.Clear(); }