private void Browse_Click(object sender, System.EventArgs e) { string fileName = UIMisc.GetOpenFilename(Text, FileName.Text, FileFilter, DefaultExt); if (fileName != "") { FileName.Text = fileName; } }
/// <summary> /// Select a list file /// </summary> /// <param name="prompt"></param> /// <param name="defaultName"></param> /// <returns></returns> public static string SelectListFileDialog( string prompt, string defaultName) { string name = UIMisc.GetOpenFilename(prompt, defaultName, "Lists (*.lst)|*.lst|All files (*.*)|*.*", "LST"); return(name); }
private void BrowseBackgroundFileButton_Click(object sender, EventArgs e) { string filter = "Files (*.jpg, *.png, .bmp, .gif)|*.jpg; *.png; .bmp; .gif|All files (*.*)|*.*"; string fileName = UIMisc.GetOpenFilename("File Name", BackgroundImageFileName.Text, filter, ".jpg"); if (fileName == "") { return; } BackgroundImageFileName.Text = fileName; }
private void Browse_Click(object sender, System.EventArgs e) { string fileName = UIMisc.GetOpenFilename(Text, FileName.Text, FileFilter, DefaultExt); if (fileName != "") { FileName.Text = fileName; } if (fileName.EndsWith(".smi", StringComparison.OrdinalIgnoreCase) && FileName.Text == "") { SpaceDelim.Checked = true; // if Smiles file then make space the default delimiter } }
private void ImportList_Click(object sender, EventArgs e) { string fileName = UIMisc.GetOpenFilename("List File to Import", "", "List Files (*.lst; *.txt)|*.lst; *.txt|All files (*.*)|*.*", "LST"); if (fileName == "") { return; } StreamReader sr = new StreamReader(fileName); List <string> list = new List <string>(); while (true) { string item = sr.ReadLine(); if (item == null) { break; } if (item.IndexOf("\r") >= 0) { item = item.Replace("\r", ""); } item = item.Trim(); if (item == "") { continue; } list.Add(item); } sr.Close(); string listText = Csv.JoinCsvString(list); ValueList.Text = listText; if (listText.Length > 0) // no text selected { ValueList.Select(0, 0); } return; }
/// <summary> /// Prompt user for structure file name and read in structure /// </summary> /// <returns></returns> public static bool ReadMoleculeFileDialog( out MoleculeMx mol, out string fileName) { while (true) { mol = null; string filter = "Molecule Files (*.mol; *.sdf; *.smi; *.helm; *.txt)|*.mol; *.sdf; *.smi; *.helm; *.hlm; *.txt;|All files (*.*)|*.*"; fileName = UIMisc.GetOpenFilename( "Retrieve Model Structure from File", "", filter, "MOL"); if (String.IsNullOrEmpty(fileName)) { return(false); } try { if (Lex.EndsWith(fileName, ".mol") || Lex.EndsWith(fileName, ".sdf")) { mol = MoleculeMx.ReadMolfile(fileName); } if (Lex.EndsWith(fileName, ".smi")) { mol = MoleculeMx.ReadSmilesFile(fileName); } else if (Lex.EndsWith(fileName, ".skc")) { mol = MoleculeMx.ReadSketchFile(fileName); } else if (Lex.EndsWith(fileName, ".helm")) { mol = MoleculeMx.ReadHelmFile(fileName); } else if (Lex.EndsWith(fileName, ".fasta")) { mol = MoleculeMx.ReadFastaFile(fileName); } else if (Lex.EndsWith(fileName, ".seq")) { mol = MoleculeMx.ReadBiopolymerSequenceFile(fileName); } else // something else, look at the contents { string txt = FileUtil.ReadFile(fileName); mol = new MoleculeMx(txt); } } catch (Exception ex) // if error clear mol and try again { mol = null; } if (NullValue.IsNull(mol)) { MessageBoxMx.ShowError("Unable to read molecule file: " + fileName); continue; // try again } return(true); } }