Exemplo n.º 1
0
        /// <summary>Internal helper.
        /// <remarks>Note! Part of internal API. Breaking changes may occur without notice. Use at own risk.</remarks>
        /// </summary>
        /// <param name="src">TBD</param>
        /// <param name="msg">TBD</param>
        /// <returns>TBD</returns>
        protected bool InternalDoMatch(string src, object msg)
        {
            var msgstr = msg == null ? "null" : msg.ToString();

            return(_sourceMatcher.IsMatch(src) && _messageMatcher.IsMatch(msgstr));
        }
        public static bool FindText(
            DataView dataView,
            IStringMatcher matcher,
            ref int rowIndex,
            ref int columnIndex)
        {
            var found = false;
            var dataTable = dataView.Table;
            var dataRows = dataTable.Rows;
            var rowCount = dataView.Count;
            var columnCount = dataTable.Columns.Count;
            var currentValueObject = dataTable.DefaultView[rowIndex][columnIndex];
            string currentValue;
            if (currentValueObject is StringField)
            {
                var stringField = currentValueObject as StringField;
                currentValue = stringField.Value;
            }
            else
            {
                currentValue = currentValueObject.ToString();
            }

            if (matcher.IsMatch(currentValue))
            {
                if (columnIndex < columnCount - 1)
                {
                    columnIndex++;
                }
                else if (rowIndex < rowCount - 1)
                {
                    rowIndex++;
                }
            }

            if (rowIndex == 0)
            {
                for (var i = columnIndex + 1; i < dataTable.Columns.Count; i++)
                {
                    var dataColumn = dataTable.Columns[i];
                    found = matcher.IsMatch(dataColumn.ColumnName);

                    if (found)
                    {
                        columnIndex = i;
                        break;
                    }
                }
            }

            if (!found)
            {
                var dataRow = dataTable.DefaultView[rowIndex].Row;

                while (true)
                {
                    found = matcher.IsMatch(dataRow[columnIndex].ToString());

                    if (found)
                    {
                        //cell.DataGridView.Rows[row].Cells[col].Selected = true;
                        // TODO
                        // cell.RowIndex = row;
                        // cell.ColumnIndex = col;
                        break;
                    }

                    if ((columnIndex + 1)%columnCount != 0)
                    {
                        columnIndex++;
                    }
                    else
                    {
                        rowIndex++;
                        columnIndex = 0;

                        if (rowIndex < rowCount)
                        {
                            dataRow = dataTable.DefaultView[rowIndex].Row;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }

            return found;
        }