예제 #1
0
        protected virtual bool DoCellValidating(int rowIndex, int columnIndex, string value)
        {
            string errorText = null;

            if (columnIndex == COLUMN_SEQUENCE && GridView.IsCurrentCellInEditMode)
            {
                var sequence = new Target(value);
                errorText = MeasuredPeptide.ValidateSequence(sequence);
                if (errorText == null)
                {
                    int iExist = Items.ToArray().IndexOf(pep => Equals(pep.Target, sequence));
                    if (iExist != -1 && iExist != rowIndex)
                    {
                        errorText = string.Format(Resources.PeptideGridViewDriver_DoCellValidating_The_sequence__0__is_already_present_in_the_list, sequence);
                    }
                }
            }
            else if (columnIndex == COLUMN_TIME && GridView.IsCurrentCellInEditMode)
            {
                string rtText = value;
                errorText = MeasuredPeptide.ValidateRetentionTime(rtText, AllowNegativeTime);
            }
            if (errorText != null)
            {
                MessageDlg.Show(MessageParent, errorText);
                return(false);
            }
            return(true);
        }
예제 #2
0
        protected virtual bool DoRowValidating(int rowIndex)
        {
            var row = GridView.Rows[rowIndex];

            if (row.IsNewRow)
            {
                return(true);
            }
            var    cell      = row.Cells[COLUMN_SEQUENCE];
            string errorText = MeasuredPeptide.ValidateSequence(new Target(cell.FormattedValue != null
                                                                    ? cell.FormattedValue.ToString()
                                                                    : null));

            if (errorText == null)
            {
                cell      = row.Cells[COLUMN_TIME];
                errorText = MeasuredPeptide.ValidateRetentionTime(cell.FormattedValue != null
                                                                      ? cell.FormattedValue.ToString()
                                                                      : null, AllowNegativeTime);
            }
            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);
        }