Ejemplo n.º 1
0
        public IReportBuilder WithDataBand(List <string> fields, double[] sizes, List <TextAlign> aligns = null, string dataSetName = "dataset", double height = 0.2)
        {
            CurrentData = new StiDataBand(MakeRectangle(0, 0, 0, height))
            {
                DataSourceName = dataSetName
            };

            var condition = new StiCondition
            {
                BackColor  = Color.FromArgb(0),
                TextColor  = Color.Transparent,
                Expression = "(Line & 1) == 1",
                Item       = StiFilterItem.Expression
            };

            CurrentData.Conditions.Add(condition);

            Page.Components.Add(CurrentData);


            var newVariable = new StiVariable()
            {
                Name  = "Xdec",
                Alias = "Xdec",
                Value = "10",
                Type  = typeof(int)
            };

            Report.Dictionary.Variables.Add(newVariable);


            CurrentData.BeforePrintEvent = new StiBeforePrintEvent("Xdec=Xdec+1;");
            CurrentData.AfterPrintEvent  = new StiAfterPrintEvent("Xdec=Xdec+1;");



            var x = 0.0;

            for (var i = 0; i < fields.Count; i++)
            {
                TextAlign align;
                if (aligns != null)
                {
                    align = aligns[i];
                }
                else
                {
                    align = Fields.FirstOrDefault(a => string.Equals(a.Item1, fields[i], StringComparison.CurrentCultureIgnoreCase))?.Item3 ?? TextAlign.Right;
                }

                var text    = "{" + $"{dataSetName}.{fields[i]}" + "}";
                var stiText = _textBuilder.New(text).WithFormat(MakeFormat(fields[i])).WithPosition(x)
                              .WithSize(sizes[i]).WithAlign((StiTextHorAlignment)align).Then();
                x += sizes[i];
                CurrentData.Components.Add(stiText);
            }

            return(this);
        }