예제 #1
0
        private void ApplyPredefinedRules()
        {
            var rule1 = new C1.Win.RulesManager.Rule()
            {
                Name       = "In Order",
                Expression = "= [UnitsOnOrder] > 0",
                Style      = new ItemStyle()
                {
                    ForeColor   = Color.DarkBlue,
                    BorderColor = Color.DarkBlue,
                    FontStyle   = FontStyle.Bold
                }
            };

            rule1.AppliesTo.Add(new FieldRange(new string[] { "UnitsOnOrder" }));
            rulesManager.Rules.Add(rule1);

            var rule2 = new C1.Win.RulesManager.Rule()
            {
                Name       = "Only Few In Stock",
                Expression = "= [UnitsInStock] < 10",
                Style      = new ItemStyle()
                {
                    ForeColor = Color.White,
                    BackColor = Color.Green
                }
            };

            rule2.AppliesTo.Add(new ItemRange(flexGrid.Rows.Fixed, flexGrid.Rows.Count - 1));
            rulesManager.Rules.Add(rule2);
        }
        private void ShowSingleValueConditionalFormattingForm(SingleValueConditionalFormattingForm form, string singleValueExpression)
        {
            if (form == null)
            {
                return;
            }

            form.ShowDialog();
            if (form.DialogResult != DialogResult.OK)
            {
                return;
            }

            var val = form.Value;

            if (string.IsNullOrEmpty(val))
            {
                return;
            }

            var itemRange        = GetItemRange(flexGrid.Selection);
            var expressionString = string.Format(singleValueExpression, val);
            var stylePreset      = form.SelectedStylePreset;
            var rule             = new C1.Win.RulesManager.Rule()
            {
                Name       = expressionString + " on " + itemRange.ToString(),
                Expression = expressionString,
                Style      = StylePresets.Highlights[stylePreset]
            };

            rule.AppliesTo.Add(itemRange);

            rulesManager.Rules.Add(rule);
        }
예제 #3
0
        private void InitForms()
        {
            // Apply default filter - show only invoices with discount
            _filterForm = new FilterEditor(c1FlexGrid1);
            var expression = new CombinationExpression();

            expression.Expressions.Add(new OperationExpression()
            {
                PropertyName    = "Discount",
                FilterOperation = FilterOperation.GreaterThan,
                Value           = 0
            });
            _filterForm.SetExpression(expression);

            // Apply default rule - bold text for major invoice records
            _rulesForm = new ConditionalFormattingForm(c1FlexGrid1);
            var rule = new C1.Win.RulesManager.Rule()
            {
                Name       = "Major Invoices",
                Expression = "=[ExtendedPrice] > 1000",
                Style      = new ItemStyle()
                {
                    FontStyle = FontStyle.Bold
                }
            };

            _rulesForm.Rules.Add(rule);
        }
        private void ApplyStyleToSelectedRange(ItemStyle style)
        {
            var itemRange        = GetItemRange(flexGrid.Selection);
            var expressionString = "= true";
            var rule             = new C1.Win.RulesManager.Rule()
            {
                Name       = expressionString + " on " + itemRange.ToString(),
                Expression = expressionString,
                Style      = style
            };

            rule.AppliesTo.Add(itemRange);

            rulesManager.Rules.Add(rule);
        }
예제 #5
0
        private void ApplyPredefinedRules()
        {
            var rule1 = new C1.Win.RulesManager.Rule()
            {
                Name       = "Product rating",
                Expression = "= true",
                Style      = new ItemStyle()
                {
                    Gradient = new GradientSettings()
                    {
                        IconList   = IconListKey.Star,
                        IconPoints = new GradientPoint[]
                        {
                            new GradientPoint(GradientPointType.MinValue),
                            new GradientPoint(GradientPointType.MaxValue)
                        }
                    }
                }
            };

            rule1.AppliesTo.Add(new FieldRange(new string[] { "UnitsOnOrder" }));
            rulesManager.Rules.Add(rule1);

            var rule2 = new C1.Win.RulesManager.Rule()
            {
                Name       = "Stock availability",
                Expression = "= true",
                Style      = new ItemStyle()
                {
                    Gradient = new GradientSettings()
                    {
                        IconList   = IconListKey.TrafficLight,
                        IconPoints = new GradientPoint[]
                        {
                            new GradientPoint(GradientPointType.MinValue),
                            new GradientPoint(GradientPointType.MaxValue)
                        }
                    }
                }
            };

            rule2.AppliesTo.Add(new FieldRange(new string[] { "UnitsInStock" }));
            rulesManager.Rules.Add(rule2);
        }
        private void ShowBetweenForm(BetweenForm form)
        {
            if (form == null)
            {
                return;
            }

            form.ShowDialog();
            if (form.DialogResult != DialogResult.OK)
            {
                return;
            }

            var minimumVal = form.MinimumValue;

            if (string.IsNullOrEmpty(minimumVal))
            {
                return;
            }

            var maximumVal = form.MaximumValue;

            if (string.IsNullOrEmpty(maximumVal))
            {
                return;
            }

            var itemRange        = GetItemRange(flexGrid.Selection);
            var expressionString = $"= {minimumVal} <= [CurrentValue] And [CurrentValue] <= {maximumVal}";
            var stylePreset      = form.SelectedStylePreset;
            var rule             = new C1.Win.RulesManager.Rule()
            {
                Name       = expressionString + " on " + itemRange.ToString(),
                Expression = expressionString,
                Style      = StylePresets.Highlights[stylePreset]
            };

            rule.AppliesTo.Add(itemRange);

            rulesManager.Rules.Add(rule);
        }