protected virtual bool DoRowValidating(int rowIndex) { var row = GridView.Rows[rowIndex]; if (row.IsNewRow) { return(true); } var cell = row.Cells[EditIonMobilityLibraryDlg.COLUMN_SEQUENCE]; string errorText = ValidatingIonMobilityPeptide.ValidateSequence(cell.FormattedValue != null ? cell.FormattedValue.ToString() : null); if (errorText == null) { cell = row.Cells[EditIonMobilityLibraryDlg.COLUMN_COLLISIONAL_CROSS_SECTION]; errorText = ValidatingIonMobilityPeptide.ValidateCollisionalCrossSection(cell.FormattedValue != null ? cell.FormattedValue.ToString() : null); } if (errorText == null) { cell = row.Cells[EditIonMobilityLibraryDlg.COLUMN_HIGH_ENERGY_DRIFT_TIME_OFFSET_MSEC]; errorText = ValidatingIonMobilityPeptide.ValidateHighEnergyDriftTimeOffsetMsec(cell.FormattedValue != null ? cell.FormattedValue.ToString() : null); } if (errorText == null) { // ReSharper disable once PossibleNullReferenceException var sequence = row.Cells[EditIonMobilityLibraryDlg.COLUMN_SEQUENCE].FormattedValue.ToString(); int iExist = Items.ToArray().IndexOf(pep => Equals(pep.Sequence, sequence)); if (iExist != -1 && iExist != rowIndex) { errorText = string.Format(Resources.CollisionalCrossSectionGridViewDriverBase_DoRowValidating_The_sequence__0__is_already_present_in_the_list_, sequence); } } if (errorText != null) { bool messageShown = false; try { GridView.CurrentCell = cell; MessageDlg.Show(MessageParent, errorText); messageShown = true; GridView.BeginEdit(true); } catch (Exception) { // Exception may be thrown if current cell is changed in the wrong context. if (!messageShown) { MessageDlg.Show(MessageParent, errorText); } } return(false); } return(true); }
private void LoadLibrary(IEnumerable <DbIonMobilityPeptide> library) { LibraryPeptideList.Clear(); foreach (var peptide in library) { var val = new ValidatingIonMobilityPeptide(peptide); if (!LibraryPeptideList.Any(p => p.Equals(val))) { LibraryPeptideList.Add(val); } } }
private void LoadLibrary(IEnumerable <DbIonMobilityPeptide> library) { LibraryPeptideList.Clear(); foreach (var peptide in library) { var val = new ValidatingIonMobilityPeptide(peptide.Sequence, peptide.CollisionalCrossSection, peptide.HighEnergyDriftTimeOffsetMsec); if (!LibraryPeptideList.Any(p => p.Equals(val))) { LibraryPeptideList.Add(val); } } }