/// <summary> /// Checks that the ID file that the user has added is valid input. This is called /// each time a new ID file is added. The method first checks that the ID header is /// interpretable and then attempts to read the first identification. A popup is displayed /// if there is an error. /// </summary> private bool ValidateIdentificationFile(IdentificationFileForDataGrid idFile) { //TODO bool valid = true; return(valid); }
/// <summary> /// Deletes a file (ID or spectra file) from the data grid. /// </summary> private void DeleteFileFromGrid_Click(object sender, RoutedEventArgs e) { SpectraFileForDataGrid spectraFile = (sender as Button).DataContext as SpectraFileForDataGrid; if (spectraFile != null) { spectraFiles.Remove(spectraFile); if (!spectraFiles.Any()) { DragAndDropHelperLabelSpectraFiles.Visibility = Visibility.Visible; } return; } IdentificationFileForDataGrid idFile = (sender as Button).DataContext as IdentificationFileForDataGrid; if (idFile != null) { idFiles.Remove(idFile); if (!idFiles.Any()) { DragAndDropHelperLabelIdFiles.Visibility = Visibility.Visible; } return; } }
private void AddAFile(string filePath) { string filename = Path.GetFileName(filePath); string theExtension = Path.GetExtension(filename).ToLowerInvariant(); switch (theExtension) { case ".raw": if (!ThermoStaticData.CheckForMsFileReader()) { AddNotification("Warning! Cannot find Thermo MSFileReader (v3.0 SP2 is preferred); a crash may result from searching this .raw file"); } goto case ".mzml"; case ".mzml": SpectraFileForDataGrid spectraFile = new SpectraFileForDataGrid(filePath); if (!spectraFilesForDataGrid.Select(f => f.FilePath).Contains(spectraFile.FilePath)) { spectraFilesForDataGrid.Add(spectraFile); } if (string.IsNullOrEmpty(OutputFolderTextBox.Text)) { var pathOfFirstSpectraFile = Path.GetDirectoryName(spectraFilesForDataGrid.First().FilePath); OutputFolderTextBox.Text = Path.Combine(pathOfFirstSpectraFile, @"FlashLFQ_$DATETIME"); } break; case ".txt": case ".tsv": case ".psmtsv": case ".tabular": IdentificationFileForDataGrid identFile = new IdentificationFileForDataGrid(filePath); if (!identFilesForDataGrid.Select(f => f.FilePath).Contains(identFile.FilePath) && !identFile.FileName.Equals("ExperimentalDesign.tsv")) { identFilesForDataGrid.Add(identFile); } break; default: AddNotification("Unrecognized file type: " + theExtension); break; } }
/// <summary> /// Handles adding a file (spectra or ID file). The source can be by drag+drop or through /// clicking one of the "Add" buttons. /// </summary> private void AddAFile(string filePath) { string filename = Path.GetFileName(filePath); string theExtension = Path.GetExtension(filename).ToLowerInvariant(); if (theExtension == ".raw") { var licenceAgreement = LicenceAgreementSettings.ReadLicenceSettings(); if (!licenceAgreement.HasAcceptedThermoLicence) { var thermoLicenceWindow = new ThermoLicenceAgreementWindow(); thermoLicenceWindow.LicenceText.AppendText(ThermoRawFileReader.ThermoRawFileReaderLicence.ThermoLicenceText); var dialogResult = thermoLicenceWindow.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value == true) { try { licenceAgreement.AcceptLicenceAndWrite(); } catch (Exception e) { MessageBox.Show(e.Message); } } else { return; } } } switch (theExtension) { case ".raw": case ".mzml": List <int> existingDefaultSampleNumbers = spectraFiles.Where(p => p.Condition == DefaultCondition) .Select(p => p.Sample) .Distinct() .OrderBy(p => p).ToList(); int sampleNumber = 1; for (int i = 1; i < int.MaxValue; i++) { if (!existingDefaultSampleNumbers.Contains(i)) { sampleNumber = i; break; } } SpectraFileForDataGrid spectraFile = new SpectraFileForDataGrid(filePath, DefaultCondition, sampleNumber, 1, 1); if (!spectraFiles.Select(f => f.FilePath).Contains(spectraFile.FilePath)) { CheckForExistingExperimentalDesignFile(spectraFile); spectraFiles.Add(spectraFile); DragAndDropHelperLabelSpectraFiles.Visibility = Visibility.Hidden; } if (string.IsNullOrEmpty(OutputFolderTextBox.Text)) { var pathOfFirstSpectraFile = Path.GetDirectoryName(spectraFiles.First().FilePath); OutputFolderTextBox.Text = Path.Combine(pathOfFirstSpectraFile, @"FlashLFQ_$DATETIME"); } break; case ".txt": case ".tsv": case ".psmtsv": case ".tabular": IdentificationFileForDataGrid identFile = new IdentificationFileForDataGrid(filePath); if (!idFiles.Select(f => f.FilePath).Contains(identFile.FilePath) && !identFile.FileName.Equals("ExperimentalDesign.tsv")) { bool valid = ValidateIdentificationFile(identFile); if (valid) { idFiles.Add(identFile); DragAndDropHelperLabelIdFiles.Visibility = Visibility.Hidden; } } break; default: //TODO: change this to popup AddNotification("Unrecognized file type: " + theExtension); break; } }