private void loadInput() { if (!File.Exists(textBox1.Text)) { MessageBox.Show("Not a valid file! \"" + textBox1.Text + "\" does not exist. Please try again."); } else { this.tableLayoutPanel1.SuspendLayout(); IndigoObject savedStrut = XmlSaver.decryptIndigo(_indigo, openFileDialog1.FileName); _chemStructures.Add(savedStrut); _rules = XmlSaver.readRules(openFileDialog1.FileName); renderMolecule(_chemStructures[0]); tableLayoutPanel1.Controls.Clear(); tableLayoutPanel1.RowStyles.Clear(); tableLayoutPanel1.ColumnStyles.Clear(); tableLayoutPanel1.RowCount = 0; tableLayoutPanel1.ColumnCount = 0; tableLayoutPanel1.Controls.Clear(); //Load R groups int i = 0; foreach (IndigoObject rgroup in _chemStructures[0].iterateAtoms()) { if (rgroup.symbol().Equals("R")) { Label temp = new Label(); temp.Name = rgroup.index().ToString(); temp.Text = "Mass at R # " + rgroup.index(); rlabels.Add(temp); GenericGroup rGroup = new GenericGroup(); TextBox temp2 = new TextBox(); temp2.Name = rgroup.index().ToString(); temp2.Text = "<Input Mass at R # " + rgroup.index() + ">"; temp2.Width = 150; rGroup.interfaceText = temp2; rGroup.index = rgroup.index(); rmasses.Add(rGroup); tableLayoutPanel1.Controls.Add(rlabels.Last(), 0 /* Column Index */, i /* Row index */); tableLayoutPanel1.Controls.Add(rmasses.Last().interfaceText, 1 /* Column Index */, i /* Row index */); i++; //rGrpINdex to help save stuff rGrpIndex.Add(rgroup.index()); } } Console.WriteLine(i); if (i == 0) { Label temp = new Label(); temp.Text = "No R Groups Found. "; tableLayoutPanel1.Controls.Add(temp, 0 /* Column Index */, i /* Row index */); } this.tableLayoutPanel1.ResumeLayout(); this.Refresh(); } }
//Edit dialogue. private void Button2_Click(object sender, EventArgs e) { Indigo _indigo = new Indigo(); IndigoObject savedStrut = XmlSaver.decryptIndigo(_indigo, openFileDialog1.FileName); List <IndigoObject> chemStructures = new List <IndigoObject>(); chemStructures.Add(savedStrut); List <fragmentationRule> _rules = XmlSaver.readRules(openFileDialog1.FileName); TemplateBuilder g = new TemplateBuilder(chemStructures, _indigo, _rules); g.ShowDialog(); this.Close(); }