private void OpenFile_Click(object sender, RoutedEventArgs e) { var doc = new Document(); int j; OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "FASTA Files (*.fasta)|*.fasta|Sequence Files (*.seq) |*.seq| Protein Data Bank (*.pdb)|*.pdb"; if (dlg.ShowDialog().GetValueOrDefault()) { fileName = String.Copy(dlg.FileName); using (StreamReader sr = new StreamReader(dlg.FileName)) { bool flag = true; int i = dockingManager.Documents.Count; for (j = 0; j < i; j++) { if (dlg.FileName == dockingManager.Documents[j].Tag.ToString()) { flag = false; break; } } if (flag == true) { doc = new Document() { Title = System.IO.Path.GetFileName(dlg.FileName) }; doc.Show(dockingManager); doc.TextContent = sr.ReadToEnd(); doc.Tag = dlg.FileName.ToString(); doc.Activate(); } else { dockingManager.ActiveDocument = dockingManager.Documents[j]; } } } }
private void New_click(object sender, RoutedEventArgs e) { string title = "Sequence 0"; int i = 1; while (dockingManager.Documents.Any(d => d.Title == title)) { title = "Sequence " + i.ToString(); i++; } var doc = new Document() { Title = title }; doc.Show(dockingManager); doc.Tag = ""; doc.Activate(); }
private void dockingManager_Drop(object sender, DragEventArgs e) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string n in files) { string format = System.IO.Path.GetExtension(@n).ToString(); if (format == ".fasta" || format == ".seq" || format == ".pdb") { StreamReader sr = new StreamReader(@n); var doc = new Document() { Title = System.IO.Path.GetFileName(@n).ToString() }; doc.Show(dockingManager); doc.TextContent = sr.ReadToEnd(); doc.Tag = n; doc.Activate(); sr.Close(); sr = null; } else { MessageBox.Show("Unsupported File Format.Only fasta files are supported.", "EggPlant"); } } }