private void SupportedFormatsInfoDlg_Load(object sender, EventArgs e) { int temp; if (MoleculeLoader.supportedFormats == null) { MoleculeLoader.CreateOpenFilter(out temp, null); } //FileStream fs = new FileStream("formats.txt", FileMode.Create); //StreamWriter file = new StreamWriter(fs, Encoding.UTF8); foreach (IChemFormatMatcher format in MoleculeLoader.supportedFormats) { StringBuilder exts = new StringBuilder(); string io = ""; if (format.ReaderClassName != null && format.ReaderClassName.Length > 0) { io += "Read"; } if (format.WriterClassName != null && format.WriterClassName.Length > 0) { if (io.Length > 0) { io += "/Write"; } else { io += "Write"; } } int idx = 0; foreach (string ext in format.NameExtensions) { if (idx++ > 0) { exts.Append(","); } exts.Append("*."); exts.Append(ext); } ListViewItem item = new ListViewItem(new string[] { format.FormatName, exts.ToString(), format.MIMEType, format.XMLBased.ToString(), io }); listView1.Items.Add(item); //file.WriteLine(format.FormatName + " | " + exts.ToString()); } //file.Close(); //fs.Close(); }
public void OpenMoleculeDialog() { OpenFileDialog dialog = new OpenFileDialog(); // TODO: Build filter from known formats int filterIdx; dialog.Filter = MoleculeLoader.CreateOpenFilter(out filterIdx, dialog.InitialDirectory); dialog.FilterIndex = filterIdx; if (dialog.ShowDialog() == DialogResult.OK) { LoadFile(dialog.FileName); } dialog.Dispose(); }
private void OpenMolecule() { if (openDlg == null) { openDlg = new OpenFileDialog(); openDlg.Title = "Open Molecule"; int filterIdx; //if (lastLocation == null) // lastLocation = Application.StartupPath; //openDlg.InitialDirectory = Environment.CurrentDirectory; openDlg.Filter = MoleculeLoader.CreateOpenFilter(out filterIdx, null); } //dlg.FilterIndex = filterIdx; if (openDlg.ShowDialog(this) == DialogResult.OK) { OpenMolecule(openDlg.FileName); } //dlg.Dispose(); }