Exemplo n.º 1
0
        /// <summary>
        /// Gets the data from a datasource that the object is connected to.
        /// </summary>
        /// <remarks>
        /// This method is called by the report engine before processing the object.
        /// <para/>Do not call it directly. You may override it if you are developing a new FastReport component.
        /// In this method you should get the data from a datasource that the object is connected to.
        /// </remarks>
        public virtual void GetData()
        {
            Hyperlink.Calculate();

            if (!String.IsNullOrEmpty(Bookmark))
            {
                object value = Report.Calc(Bookmark);
                Bookmark = value == null ? "" : value.ToString();
            }
        }
Exemplo n.º 2
0
 internal string CalcAndFormatExpression(string expression, int expressionIndex)
 {
     try
     {
         return(FormatValue(Report.Calc(expression), expressionIndex));
     }
     catch (Exception e)
     {
         throw new Exception(Name + ": " + Res.Get("Messages,ErrorInExpression") + ": " + expression, e.InnerException);
     }
 }
Exemplo n.º 3
0
 internal void ResetGroupValue()
 {
     if (!string.IsNullOrEmpty(Condition))
     {
         groupValue = Report.Calc(Condition);
     }
     else
     {
         throw new GroupHeaderHasNoGroupCondition(Name);
     }
 }
Exemplo n.º 4
0
 /// <inheritdoc/>
 public override void GetData()
 {
     base.GetData();
     if (!String.IsNullOrEmpty(DataColumn))
     {
         object value = Report.GetColumnValue(DataColumn);
         Text = value == null ? "" : value.ToString();
     }
     else if (!String.IsNullOrEmpty(Expression))
     {
         object value = Report.Calc(Expression);
         Text = value == null ? "" : value.ToString();
     }
 }
Exemplo n.º 5
0
        internal bool GroupValueChanged()
        {
            object value = Report.Calc(Condition);

            if (FGroupValue == null)
            {
                if (value == null)
                {
                    return(false);
                }
                return(true);
            }
            return(!FGroupValue.Equals(value));
        }
Exemplo n.º 6
0
        /// <inheritdoc/>
        public override void GetData()
        {
            base.GetData();

            // process expressions
            if (AllowExpressions)
            {
                if (!String.IsNullOrEmpty(Brackets))
                {
                    string[]     brackets = Brackets.Split(new char[] { ',' });
                    FindTextArgs args     = new FindTextArgs();
                    args.Text         = Text;
                    args.OpenBracket  = brackets[0];
                    args.CloseBracket = brackets[1];
                    int expressionIndex = 0;

                    while (args.StartIndex < args.Text.Length)
                    {
                        string expression = CodeUtils.GetExpression(args, false);
                        if (expression == "")
                        {
                            break;
                        }

                        string formattedValue = CalcAndFormatExpression(expression, expressionIndex);
                        args.Text        = args.Text.Remove(args.StartIndex, args.EndIndex - args.StartIndex);
                        args.Text        = args.Text.Insert(args.StartIndex, formattedValue);
                        args.StartIndex += formattedValue.Length;
                        expressionIndex++;
                    }
                    Text = args.Text;
                }
            }

            // process highlight
            Variant varValue = new Variant(Value);

            foreach (HighlightCondition condition in Highlight)
            {
                if ((bool)Report.Calc(condition.Expression, varValue) == true)
                {
                    ApplyCondition(condition);
                    break;
                }
            }

            // process AutoShrink
            ProcessAutoShrink();
        }
Exemplo n.º 7
0
 /// <inheritdoc/>
 public override void GetData()
 {
     base.GetData();
     if (!String.IsNullOrEmpty(DataColumn))
     {
         object  value    = Report.GetColumnValue(DataColumn);
         Variant varValue = value == null ? new Variant(0) : new Variant(value);
         Checked = varValue == true || (varValue.IsNumeric && varValue != 0);
     }
     else if (!String.IsNullOrEmpty(Expression))
     {
         object value = Report.Calc(Expression);
         Checked = value is bool && (bool)value == true;
     }
     if (!Checked && HideIfUnchecked)
     {
         Visible = false;
     }
 }
Exemplo n.º 8
0
        internal bool GroupValueChanged()
        {
            object value = null;

            if (!string.IsNullOrEmpty(Condition))
            {
                value = Report.Calc(Condition);
            }
            else
            {
                throw new GroupHeaderHasNoGroupCondition(Name);
            }
            if (groupValue == null)
            {
                if (value == null)
                {
                    return(false);
                }
                return(true);
            }
            return(!groupValue.Equals(value));
        }
Exemplo n.º 9
0
 internal void ResetGroupValue()
 {
     FGroupValue = Report.Calc(Condition);
 }
Exemplo n.º 10
0
        /// <inheritdoc/>
        public override void Draw(FRPaintEventArgs e)
        {
            if (IsDesigning)
            {
                return;
            }

            Graphics   g        = e.Graphics;
            RectangleF pageRect = new RectangleF(0, 0,
                                                 WidthInPixels - 1 / e.ScaleX, HeightInPixels - 1 / e.ScaleY);
            RectangleF printableRect = new RectangleF(
                LeftMargin * Units.Millimeters,
                TopMargin * Units.Millimeters,
                (PaperWidth - LeftMargin - RightMargin) * Units.Millimeters,
                (PaperHeight - TopMargin - BottomMargin) * Units.Millimeters);

            DrawBackground(e, pageRect);
            Border.Draw(e, printableRect);
            if (Watermark.Enabled)
            {
                if (!Watermark.ShowImageOnTop)
                {
                    Watermark.DrawImage(e, pageRect, Report, IsPrinting);
                }
                if (!Watermark.ShowTextOnTop)
                {
                    Watermark.DrawText(e, pageRect, Report, IsPrinting);
                }
            }

            float leftMargin = (int)Math.Round(LeftMargin * Units.Millimeters * e.ScaleX);
            float topMargin  = (int)Math.Round(TopMargin * Units.Millimeters * e.ScaleY);

            g.TranslateTransform(leftMargin, topMargin);

            try
            {
                foreach (Base c in AllObjects)
                {
                    if (c is ReportComponentBase && c.HasFlag(Flags.CanDraw))
                    {
                        ReportComponentBase obj = c as ReportComponentBase;
                        if (!IsPrinting)
                        {
#if !MONO
                            if (!obj.IsVisible(e))
                            {
                                continue;
                            }
#endif
                        }
                        else
                        {
                            // Apply printable expression if needed.
                            if (!String.IsNullOrEmpty(obj.PrintableExpression))
                            {
                                string[] expressions = Code.CodeUtils.GetExpressions(obj.PrintableExpression, "[", "]");
                                foreach (string str in expressions)
                                {
                                    object expression = Report.Calc(str);
                                    if (expression is bool)
                                    {
                                        obj.Printable = (bool)expression;
                                    }
                                }
                            }
                            if (!obj.Printable)
                            {
                                continue;
                            }
                            else if (obj.Parent is BandBase && !(obj.Parent as BandBase).Printable)
                            {
                                continue;
                            }
                        }
                        obj.SetDesigning(false);
                        obj.SetPrinting(IsPrinting);
                        obj.Draw(e);
                        obj.SetPrinting(false);
                    }
                }
            }
            finally
            {
                g.TranslateTransform(-leftMargin, -topMargin);
            }

            if (Watermark.Enabled)
            {
                if (Watermark.ShowImageOnTop)
                {
                    Watermark.DrawImage(e, pageRect, Report, IsPrinting);
                }
                if (Watermark.ShowTextOnTop)
                {
                    Watermark.DrawText(e, pageRect, Report, IsPrinting);
                }
            }
        }
Exemplo n.º 11
0
 internal string CalcAndFormatExpression(string expression, int expressionIndex)
 {
     return(FormatValue(Report.Calc(expression), expressionIndex));
 }