Exemplo n.º 1
0
        private void SetFilterInfo(DataGridViewRow row, FilterInfo filterInfo)
        {
            if (filterInfo.ColumnDescriptor == null)
            {
                row.Cells[colFilterColumn.Index].Value       = filterInfo.FilterSpec.Column;
                row.Cells[colFilterColumn.Index].Style.Font  = new Font(dataGridViewFilter.Font, FontStyle.Strikeout);
                row.Cells[colFilterColumn.Index].ToolTipText = Resources.CustomizeViewForm_SetFilterInfo_This_column_does_not_exist;
            }
            else
            {
                row.Cells[colFilterColumn.Index].Value       = filterInfo.ColumnDescriptor.GetColumnCaption(ColumnCaptionType.localized);
                row.Cells[colFilterColumn.Index].Style.Font  = dataGridViewFilter.Font;
                row.Cells[colFilterColumn.Index].ToolTipText = null;
                row.Cells[colFilterOperand.Index].Value      = filterInfo.FilterSpec.Predicate.GetOperandDisplayText(filterInfo.ColumnDescriptor);
            }
            var filterOpCell = (DataGridViewComboBoxCell)row.Cells[colFilterOperation.Index];

            filterOpCell.Value = filterInfo.FilterSpec.Predicate.FilterOperation.DisplayName;
            var filterOpItems = FilterOperations.ListOperations()
                                .Where(filterOp => filterOp == filterInfo.FilterSpec.Predicate.FilterOperation ||
                                       filterInfo.ColumnDescriptor == null ||
                                       filterOp.IsValidFor(filterInfo.ColumnDescriptor))
                                .Select(filterOp => filterOp.DisplayName)
                                .ToArray();

            filterOpCell.DataSource = filterOpItems;
            if (filterInfo.FilterSpec.Operation.GetOperandType(filterInfo.ColumnDescriptor) == null)
            {
                row.Cells[colFilterOperand.Index].ReadOnly        = true;
                row.Cells[colFilterOperand.Index].Style.BackColor = Color.DarkGray;
            }
            else
            {
                row.Cells[colFilterOperand.Index].ReadOnly        = false;
                row.Cells[colFilterOperand.Index].Style.BackColor = colFilterOperand.DefaultCellStyle.BackColor;
            }
            foreach (DataGridViewCell cell in row.Cells)
            {
                if (filterInfo.Error != null)
                {
                    cell.Style.BackColor = Color.Red;
                    cell.ToolTipText     = filterInfo.Error;
                }
                else
                {
                    cell.Style.BackColor = dataGridViewFilter.DefaultCellStyle.BackColor;
                    cell.ToolTipText     = null;
                }
            }
        }
Exemplo n.º 2
0
 private void PopulateCombo(ComboBox comboBox, String hasAnyValueCaption, DataSchema dataSchema,
                            Type propertyType)
 {
     comboBox.Items.Clear();
     foreach (var filterOperation in FilterOperations.ListOperations())
     {
         if (!filterOperation.IsValidFor(dataSchema, propertyType))
         {
             continue;
         }
         string displayName;
         if (filterOperation == FilterOperations.OP_HAS_ANY_VALUE)
         {
             displayName = hasAnyValueCaption;
         }
         else
         {
             displayName = filterOperation.DisplayName;
         }
         comboBox.Items.Add(new FilterItem(displayName, filterOperation));
     }
 }
Exemplo n.º 3
0
 private IFilterOperation FilterOperationFromDisplayName(string displayName)
 {
     return(FilterOperations.ListOperations().FirstOrDefault(filterOp => filterOp.DisplayName == displayName));
 }