123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.ComponentModel;
- namespace FastReport.Data
- {
- /// <summary>
- /// Represents the collection of system variables.
- /// </summary>
- public class SystemVariables : ParameterCollection
- {
- internal SystemVariables(Base owner) : base(owner)
- {
- Add(new DateVariable());
- Add(new PageVariable());
- Add(new TotalPagesVariable());
- Add(new PageNVariable());
- Add(new PageNofMVariable());
- Add(new RowVariable());
- Add(new AbsRowVariable());
- Add(new PageMacroVariable());
- Add(new TotalPagesMacroVariable());
- Add(new CopyNameMacroVariable());
- Add(new HierarchyLevelVariable());
- Add(new HierarchyRowNoVariable());
- }
- }
- /// <summary>
- /// Represents the base class for system variables.
- /// </summary>
- public class SystemVariable : Parameter
- {
- /// <summary>
- /// This property is not relevant to this class.
- /// </summary>
- [Browsable(false)]
- public new string Expression
- {
- get { return base.Expression; }
- set { base.Expression = value; }
- }
- /// <summary>
- /// This property is not relevant to this class.
- /// </summary>
- [Browsable(false)]
- public new string Description
- {
- get { return base.Description; }
- set { base.Description = value; }
- }
- /// <inheritdoc/>
- public override bool CanContain(Base child)
- {
- return false;
- }
- }
- /// <summary>
- /// Returns date and time of the report's start.
- /// </summary>
- public class DateVariable : SystemVariable
- {
- /// <inheritdoc/>
- public override object Value
- {
- get { return Report.Engine.Date; }
- }
- internal DateVariable()
- {
- Name = "Date";
- DataType = typeof(DateTime);
- }
- }
- /// <summary>
- /// Returns current page number.
- /// </summary>
- public class PageVariable : SystemVariable
- {
- /// <inheritdoc/>
- public override object Value
- {
- get { return Report.Engine.PageNo; }
- }
- internal PageVariable()
- {
- Name = "Page";
- DataType = typeof(int);
- }
- }
- /// <summary>
- /// Returns total number of pages in the report. To use this variable, you need
- /// to enable the report's double pass.
- /// </summary>
- public class TotalPagesVariable : SystemVariable
- {
- /// <inheritdoc/>
- public override object Value
- {
- get { return Report.Engine.TotalPages; }
- }
- internal TotalPagesVariable()
- {
- Name = "TotalPages";
- DataType = typeof(int);
- }
- }
- /// <summary>
- /// Returns a string containing the current page number in a form "Page N".
- /// </summary>
- public class PageNVariable : SystemVariable
- {
- /// <inheritdoc/>
- public override object Value
- {
- get { return Report.Engine.PageN; }
- }
- internal PageNVariable()
- {
- Name = "PageN";
- DataType = typeof(string);
- }
- }
- /// <summary>
- /// Returns a string containing the current page number and total pages in a form "Page N of M".
- /// To use this variable, you need to enable the report's double pass.
- /// </summary>
- public class PageNofMVariable : SystemVariable
- {
- /// <inheritdoc/>
- public override object Value
- {
- get { return Report.Engine.PageNofM; }
- }
- internal PageNofMVariable()
- {
- Name = "PageNofM";
- DataType = typeof(string);
- }
- }
- /// <summary>
- /// Returns data row number inside the group. This value is reset at the start of a new group.
- /// </summary>
- public class RowVariable : SystemVariable
- {
- /// <inheritdoc/>
- public override object Value
- {
- get { return Report.Engine.RowNo; }
- }
- internal RowVariable()
- {
- Name = "Row#";
- DataType = typeof(int);
- }
- }
- /// <summary>
- /// Returns absolute number of data row. This value is never reset at the start of a new group.
- /// </summary>
- public class AbsRowVariable : SystemVariable
- {
- /// <inheritdoc/>
- public override object Value
- {
- get { return Report.Engine.AbsRowNo; }
- }
- internal AbsRowVariable()
- {
- Name = "AbsRow#";
- DataType = typeof(int);
- }
- }
- /// <summary>
- /// Returns current page number.
- /// <para/>This variable is actually a macro. Its value is substituted when the component is viewed in
- /// the preview window. That means you cannot use it in an expression.
- /// </summary>
- public class PageMacroVariable : SystemVariable
- {
- /// <inheritdoc/>
- public override object Value
- {
- get { return "[PAGE#]"; }
- }
- internal PageMacroVariable()
- {
- Name = "Page#";
- DataType = typeof(int);
- }
- }
- /// <summary>
- /// Returns the number of total pages in the report.
- /// <para/>This variable is actually a macro. Its value is substituted when the component is viewed in
- /// the preview window. That means you cannot use it in an expression.
- /// </summary>
- public class TotalPagesMacroVariable : SystemVariable
- {
- /// <inheritdoc/>
- public override object Value
- {
- get { return "[TOTALPAGES#]"; }
- }
- internal TotalPagesMacroVariable()
- {
- Name = "TotalPages#";
- DataType = typeof(int);
- }
- }
- /// <summary>
- /// Returns the name of the printed copy.
- /// <para/>This variable is actually a macro. Its value is substituted when the component is viewed in
- /// the preview window. That means you cannot use it in an expression.
- /// </summary>
- public class CopyNameMacroVariable : SystemVariable
- {
- /// <inheritdoc/>
- public override object Value
- {
- get { return "[COPYNAME#]"; }
- }
- internal CopyNameMacroVariable()
- {
- Name = "CopyName#";
- DataType = typeof(string);
- }
- }
- /// <summary>
- /// Returns a level of hierarchy in the hierarchical report.
- /// </summary>
- public class HierarchyLevelVariable : SystemVariable
- {
- /// <inheritdoc/>
- public override object Value
- {
- get { return Report.Engine.HierarchyLevel; }
- }
- internal HierarchyLevelVariable()
- {
- Name = "HierarchyLevel";
- DataType = typeof(int);
- }
- }
- /// <summary>
- /// Returns the row number like "1.2.1" in the hierarchical report.
- /// </summary>
- public class HierarchyRowNoVariable : SystemVariable
- {
- /// <inheritdoc/>
- public override object Value
- {
- get { return Report.Engine.HierarchyRowNo; }
- }
- internal HierarchyRowNoVariable()
- {
- Name = "HierarchyRow#";
- DataType = typeof(string);
- }
- }
- }
|