public void SetExpression(string expression) { expressionLabel.Text = expression; RebindData(); SelectedFunction.Function = expression; if (!SelectedFunction.IsExpressionParsed) { return; } var errors = ""; foreach (var filter in SelectedFunction.Filters) { var filterObject = filterObjects.FirstOrDefault(o => o.Name == filter.a.ExpressionParamName); if (filterObject == null) { errors += filter.a.ExpressionParamName + ExpressionResolver.GetOperatorString(filter.b) + filter.c + "\n"; continue; } filterObject.Selected = true; filterObject.Operator = filter.b; filterObject.Value = filter.c; } if (!string.IsNullOrEmpty(errors)) { MessageBox.Show(this, "Невозможно отобразить следующие критерии:\n" + errors, "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } fastGrid.DataBind(filterObjects); }
public TopFilterControl() { InitializeComponent(); // 4 refresh button refreshButtonColors = new[] { refreshButton.BackColor, HslColor.AdjuctBrightness(refreshButton.BackColor, 0.9f), HslColor.AdjuctBrightness(refreshButton.BackColor, 0.85f), HslColor.AdjuctBrightness(refreshButton.BackColor, 0.8f), HslColor.AdjuctBrightness(refreshButton.BackColor, 0.85f), HslColor.AdjuctBrightness(refreshButton.BackColor, 0.9f), refreshButton.BackColor, HslColor.AdjuctBrightness(refreshButton.BackColor, 1.1f), HslColor.AdjuctBrightness(refreshButton.BackColor, 1.15f), HslColor.AdjuctBrightness(refreshButton.BackColor, 1.2f), HslColor.AdjuctBrightness(refreshButton.BackColor, 1.15f), HslColor.AdjuctBrightness(refreshButton.BackColor, 1.1f) }; var blank = new FilterObject(); fastGrid.Columns.Add(new FastColumn(blank.Property(p => p.Selected), "*") { ColumnWidth = 30, ImageList = gridImageList, IsHyperlinkStyleColumn = true, HyperlinkActiveCursor = Cursors.Hand, SortOrder = FastColumnSort.Descending }); fastGrid.Columns.Add(new FastColumn(blank.Property(p => p.Group), Localizer.GetString("TitleGroup")) { ColumnWidth = 120, SortOrder = FastColumnSort.Descending }); fastGrid.Columns.Add(new FastColumn(blank.Property(p => p.Title), Localizer.GetString("TitleCriterion")) { //SortOrder = FastColumnSort.Ascending }); fastGrid.Columns.Add(new FastColumn(blank.Property(p => p.Operator), " ") { ColumnWidth = 30, IsHyperlinkStyleColumn = true, HyperlinkActiveCursor = Cursors.Hand, formatter = v => ExpressionResolver.GetOperatorString((ExpressionOperator)v) }); fastGrid.Columns.Add(new FastColumn(blank.Property(p => p.Value), Localizer.GetString("TitleValue")) { IsEditable = true }); RebindData(); fastGrid.FieldValueChanged += delegate { UpdateExpression(); }; collapseButton.Click += (sender, args) => { if (CollapseButtonClicked != null) { CollapseButtonClicked(this, new EventArgs()); } }; refreshButton.Click += (sender, args) => { if (RefreshButtonClicked != null) { RefreshButtonClicked(this, new EventArgs()); } }; createPortfolioButton.Click += (sender, args) => { if (CreatePortfolioButtonClicked != null) { CreatePortfolioButtonClicked(this, new EventArgs()); } }; // secret button showExpressionLabelButton.Click += (sender, args) => { expressionLabel.Visible = !expressionLabel.Visible; }; }