public Compound(Molecule mol, string fileName, string directory, int compoundType, string formula, int compoundState, bool isTarget, double weight, double density, Unit mols, Unit mass, Unit volume) { molFileName = fileName; this.directory = directory; this.type = compoundType; this.molecule = mol; this.state = compoundState; this.isTarget = isTarget; this.density = density; this.mols = mols; this.mass = mass; this.volume = volume; DisplayRefNameWhenDrawn = false; }
public Compound(Molecule mol) { this.molecule = mol; this.mols = new Unit(0, "mol", (int)UNIT_POWERS.none); this.mass = new Unit(0, "g", (int)UNIT_POWERS.none); this.Volume = new Unit(0, "l", (int)UNIT_POWERS.m); DisplayRefNameWhenDrawn = false; }
public void SetProperties(int compoundType, int compoundState, Unit mols, Unit mass, Unit volume, Solution solution) { this.type = compoundType; this.state = compoundState; this.mols = mols; this.mass = mass; this.volume = volume; this.solution = solution; }
public Compound(string name, string refid, string localid, int fileid, int compoundType, int compoundState, bool isLimiting, bool isTarget, string formula, double density, Unit mols, Unit mass, Unit volume, Solution solution) { this.type = compoundType; this.molecule = new Molecule(); this.molecule.Name = name; this.refName = refid; this.localid = localid; this.fileid = fileid; this.state = compoundState; this.isLimiting = isLimiting; this.isTarget = isTarget; this.molecule.Formula = formula; this.density = density; this.mols = mols; this.mass = mass; this.volume = volume; this.solution = solution; DisplayRefNameWhenDrawn = false; }
public Compound(Molecule mol, string refname, int compoundType, int compoundState, bool isLimiting, bool isTarget, double density, Unit mols, Unit mass, Unit volume, Solution solution) { this.type = compoundType; this.refName = refname; this.molecule = mol; this.state = compoundState; this.isLimiting = isLimiting; this.isTarget = isTarget; this.density = density; this.mols = mols; this.mass = mass; this.volume = volume; this.solution = solution; DisplayRefNameWhenDrawn = false; }
private void addCompoundButton_Click(object sender, EventArgs e) { //Before anything else we check that the molecule is initialized either by formula or structure if (molecule == null) { MessageBox.Show("There is no molecular data, please enter a formula or paste a structure.", "Error"); return; } //First we get all of the values in the text boxes double density = 0, massVal = 0, molsVal = 0, volVal = 0, concVal = 0; string refname = string.Empty; try { massVal = double.Parse(massTextBox.Text); molsVal = double.Parse(molsTextBox.Text); if(densityTextBox.Enabled) density = double.Parse(densityTextBox.Text); if(volumeTextBox.Enabled) volVal = double.Parse(volumeTextBox.Text); if(concentrationTextBox.Enabled) concVal = double.Parse(concentrationTextBox.Text); } catch (FormatException) { MessageBox.Show("Some input was not a number, please check your input and add the compound again"); return; } if (!string.IsNullOrEmpty(nameTextBox.Text)) refname = nameTextBox.Text; //Build the new compound bool isLimiting = false; bool isTarget = false; if (typeSelection.SelectedIndex == (int)COMPOUND_TYPES.Product) { //if it is the product we get the checkbox value and set limiting to false isLimiting = false; isTarget = isLimitingCheckBox.Checked; } else { isLimiting = isLimitingCheckBox.Checked; isTarget = false; } //Finally build the dictionaries Unit mols, mass, volume; mols = new Unit(molsVal, "mol", molUnitSelection.SelectedIndex); mass = new Unit(massVal, "g", massUnitSelection.SelectedIndex); volume = new Unit(volVal, "l", volumeUnitSelection.SelectedIndex); Solution solution = new Solution(solventTextBox.Text, new Unit(concVal, "mol/l",(int)UNIT_POWERS.none)); Compound comp = new Compound(molecule, refname, typeSelection.SelectedIndex, stateSelection.SelectedIndex, isLimiting, isTarget, density, mols, mass, volume, solution); if (comp.State == PHASE_STATE.Liquid) Console.WriteLine("Liquid, my mass is " + comp.Mass.ToString()); parent.AddCompound(comp); this.Close(); }
private static ObservableCollection<Compound> ReadBlock(XmlNodeList compoundList, COMPOUND_TYPES type) { ObservableCollection<Compound> returnList = new ObservableCollection<Compound>(); foreach (XmlNode node in compoundList) { string localid = string.Empty; string name = string.Empty; string refid = string.Empty; int fileid = 0; //In the files each compound is recognized by a five digit number, so we can attach mol data int state = 0; string formula = string.Empty; float density = 0.0f; Unit mols = new Unit(0, "mol", (int)UNIT_POWERS.none); Unit mass = new Unit(0, "g", (int)UNIT_POWERS.none); Unit volume = new Unit(0, "l", (int)UNIT_POWERS.none); Solution solvent = new Solution("null", new Unit(0, "mol/l", (int)UNIT_POWERS.none)); bool isLimiting = false; bool isTarget = false; foreach (XmlNode inner in node.ChildNodes) { switch (inner.Name) { case "fileid": fileid = int.Parse(inner.InnerText); break; case "localid": localid = inner.InnerText; break; case "name": name = inner.InnerText; break; case "refid": refid = inner.InnerText; break; case "formula": formula = inner.InnerText; break; case "state": string text = inner.InnerText; if (text == "solid") state = 0; if (text == "liquid") state = 1; if (text == "gas") state = 2; if (text == "solvated") state = 3; break; case "islimiting": isLimiting = bool.Parse(inner.InnerText); break; case "istarget": isTarget = bool.Parse(inner.InnerText); break; case "density": if (inner.InnerText == "null") break; density = float.Parse(inner.InnerText); break; case "mols": if(inner.InnerText == "null") break; mols = new Unit(double.Parse(inner.InnerText), inner.Attributes["unit"].Value, int.Parse(inner.Attributes["unit_power"].Value)); break; case "mass": if (inner.InnerText == "null") break; mass = new Unit(double.Parse(inner.InnerText), inner.Attributes["unit"].Value, int.Parse(inner.Attributes["unit_power"].Value)); break; case "volume": if (inner.InnerText == "null") break; volume = new Unit(double.Parse(inner.InnerText), inner.Attributes["unit"].Value, int.Parse(inner.Attributes["unit_power"].Value)); break; case "solvent": if (inner.InnerText == "null") break; solvent = new Solution(inner.InnerText, new Unit(float.Parse(inner.Attributes["conc"].Value), inner.Attributes["conc_unit"].Value, int.Parse(inner.Attributes["unit_power"].Value))); break; } } Compound c = new Compound(name, refid, localid, fileid, (int)type, state, isLimiting, isTarget, formula, density, mols, mass, volume, solvent); Console.WriteLine(c.ToString()); returnList.Add(c); } return returnList; }
public Solution(string solventName, Unit conc) { SolventName = solventName; Concentration = conc; }