private FilterControl AddFilter(EntityPhysicalField member) { var filterControl = new FilterControl(member) { Dock = DockStyle.Top }; _filterControls.Controls.Add(filterControl); filterControl.BringToFront(); filterControl.SelectNextControl(filterControl, true, true, true, false); return(filterControl); }
public FilterField(EntityPhysicalField field) { Field = field; }
public FilterControl(EntityPhysicalField field) { if (field == null) { throw new ArgumentNullException(nameof(field)); } Field = field; InitializeComponent(); _name.Text = HumanText.GetMemberName(Field); foreach (var control in new Control[] { _textBox, _date, _dateTime, _numericTextBox }) { control.Visible = false; } switch (field.DataType) { case EntityDataType.String: _control = _textBox; break; case EntityDataType.Date: _control = _date; break; case EntityDataType.DateTime: case EntityDataType.DateTimeTz: _control = _dateTime; break; case EntityDataType.Decimal: _control = _numericTextBox; break; case EntityDataType.Long: case EntityDataType.Int: _numericTextBox.NumberScale = 0; _control = _numericTextBox; break; case EntityDataType.Bool: break; default: throw new ArgumentOutOfRangeException(); } FilterType[] filterTypes; switch (field.Type) { case EntityMemberType.Foreign: filterTypes = ForeignFilterTypes; break; case EntityMemberType.Id: filterTypes = IdFilterTypes; break; default: switch (field.DataType) { case EntityDataType.String: filterTypes = TextFilterTypes; break; case EntityDataType.Date: case EntityDataType.DateTime: case EntityDataType.DateTimeTz: case EntityDataType.Decimal: case EntityDataType.Long: case EntityDataType.Int: filterTypes = OtherFilterTypes; break; case EntityDataType.Bool: filterTypes = BoolFilterTypes; break; default: throw new ArgumentOutOfRangeException(); } break; } foreach (var filterType in filterTypes) { var menuItem = new MenuItem { Text = GetFilterText(filterType), Tag = filterType }; menuItem.Click += FilterSelected; _contextMenu.MenuItems.Add(menuItem); } if (_control != null) { _control.Visible = true; } // Force an update. _filterType = FilterType.NotEqual; FilterType = Field.DataType == EntityDataType.Bool ? FilterType.IsTrue : FilterType.Equal; }