public override bool LoadData(List <System.Xml.Linq.XElement> data) { base.LoadData(data); System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.InvariantCulture; foreach (XElement xel in (from xel2 in data where xel2.Name == "InteractionParameters" select xel2).SingleOrDefault().Elements().ToList()) { VPT_IP ip = new VPT_IP { Compound1 = xel.Attribute("Compound1").Value, Compound2 = xel.Attribute("Compound2").Value, k1 = double.Parse(xel.Attribute("k1").Value, ci), k2 = double.Parse(xel.Attribute("k2").Value, ci), k3 = double.Parse(xel.Attribute("k3").Value, ci) }; Dictionary <string, VPT_IP> dic = new Dictionary <string, VPT_IP>(); dic.Add(xel.Attribute("Compound1").Value, ip); if (!this.InteractionParameters.ContainsKey(xel.Attribute("Compound1").Value)) { this.InteractionParameters.Add(xel.Attribute("Compound1").Value, dic); } else { if (!this.InteractionParameters[xel.Attribute("Compound1").Value].ContainsKey(xel.Attribute("Compound2").Value)) { this.InteractionParameters[xel.Attribute("Compound1").Value].Add(xel.Attribute("Compound2").Value, ip); } else { this.InteractionParameters[xel.Attribute("Compound1").Value][xel.Attribute("Compound2").Value] = ip; } } } return(true); }
private void VPT_Editor_Load(object sender, EventArgs e) { Loaded = false; chkUseLK.Checked = PP.UseLeeKeslerEnthalpy; List <ICompoundConstantProperties> compounds; if (GlobalSettings.Settings.CAPEOPENMode) { compounds = PP._selectedcomps.Values.Select(x => (ICompoundConstantProperties)x).ToList(); } else { compounds = PP.Flowsheet.SelectedCompounds.Values.ToList(); } foreach (ICompoundConstantProperties cp in compounds) { gt0: if (PP.InteractionParameters.ContainsKey(cp.Name)) { foreach (ICompoundConstantProperties cp2 in compounds) { if (cp.Name != cp2.Name) { if (!PP.InteractionParameters[cp.Name].ContainsKey(cp2.Name)) { //check if collection has id2 as primary id if (PP.InteractionParameters.ContainsKey(cp2.Name)) { if (!PP.InteractionParameters[cp2.Name].ContainsKey(cp.Name)) { var ip = new VPT_IP(); ip.Compound1 = cp.Name; ip.Compound2 = cp2.Name; PP.InteractionParameters[cp.CAS_Number].Add(cp2.CAS_Number, ip); PP.InteractionParameters[cp.Name].Add(cp2.Name, ip); dgvkij.Rows.Add(new object[] { cp.Name, cp2.Name, PP.InteractionParameters[cp.Name][cp2.Name].k1, PP.InteractionParameters[cp.Name][cp2.Name].k2, PP.InteractionParameters[cp.Name][cp2.Name].k3 }); } } } else { dgvkij.Rows.Add(new object[] { cp.Name, cp2.Name, PP.InteractionParameters[cp.Name][cp2.Name].k1, PP.InteractionParameters[cp.Name][cp2.Name].k2, PP.InteractionParameters[cp.Name][cp2.Name].k3 }); } } } } else { PP.InteractionParameters.Add(cp.Name, new Dictionary <string, VPT_IP>()); goto gt0; } } Loaded = true; }