using System; using System.Collections.Generic; using System.Text; using FastReport.Table; using FastReport.Utils; namespace FastReport.CrossView { /// /// The descriptor that is used to describe one element of the CrossView header. /// /// /// The class is used to define one header element of the CrossView /// (either the column element or row element). /// To set visual appearance of the element, use the /// property. /// The collection of descriptors used to represent the CrossView header is stored /// in the CrossViewObject.Data.Columns and CrossViewObject.Data.Rows properties. /// public class CrossViewHeaderDescriptor : CrossViewDescriptor { #region Fields internal string fieldName = ""; internal string measureName = ""; internal bool isGrandTotal; internal bool isTotal; internal bool isMeasure; internal int level = 0; internal int cell = 0; internal int levelsize = 1; internal int cellsize = 1; #endregion #region Properties /// /// Gets a value indicating that this is the "GrandTotal" element. /// public bool IsGrandTotal { set { isGrandTotal = value; } get { return isGrandTotal; } } /// /// Gets a value indicating that this is the "Total" element. /// public bool IsTotal { set { isTotal = value; } get { return isTotal; } } /// /// Gets a value indicating that this is the "Measure" element. /// public bool IsMeasure { set { isMeasure = value; } get { return isMeasure; } } /// /// Gets the name of field in cube. /// public string FieldName { set { fieldName = value; } get { return fieldName; } } /// /// Gets the name of measure in cube. /// public string MeasureName { set { measureName = value; } get { return measureName; } } /// /// Gets the cell coordinate. /// public int Cell { set { cell = value; } get { return cell; } } /// /// Gets the size in cell coordinate. /// public int CellSize { set { cellsize = value; } get { return cellsize; } } /// /// Gets the level coordinate. /// public int Level { set { level = value; } get { return level; } } /// /// Gets the size in level coordinate. /// public int LevelSize { set { levelsize = value; } get { return levelsize; } } #endregion #region Public Methods /// public override void Assign(CrossViewDescriptor source) { base.Assign(source); CrossViewHeaderDescriptor src = source as CrossViewHeaderDescriptor; if (src != null) { isTotal = src.isTotal; isGrandTotal = src.isGrandTotal; fieldName = src.fieldName; measureName = src.measureName; isMeasure = src.isMeasure; level = src.level; levelsize = src.levelsize; cell = src.cell; cellsize = src.cellsize; } } /// public override void Serialize(FRWriter writer) { CrossViewHeaderDescriptor c = writer.DiffObject as CrossViewHeaderDescriptor; base.Serialize(writer); writer.ItemName = "Header"; if (IsTotal != c.IsTotal) writer.WriteBool("IsTotal", IsTotal); if (IsGrandTotal != c.IsGrandTotal) writer.WriteBool("IsGrandTotal", IsGrandTotal); if (FieldName != c.FieldName) writer.WriteStr("FieldName", FieldName); if (MeasureName != c.MeasureName) writer.WriteStr("MeasureName", MeasureName); if (IsMeasure != c.IsMeasure) writer.WriteBool("IsMeasure", IsMeasure); if (Cell != c.Cell) writer.WriteInt("Cell", Cell); if (CellSize != c.CellSize) writer.WriteInt("CellSize", CellSize); if (Level != c.Level) writer.WriteInt("Level", Level); if (LevelSize != c.LevelSize) writer.WriteInt("LevelSize", LevelSize); } internal string GetName() { if (isGrandTotal) { return "GrandTotal"; }; if (IsMeasure) { return measureName; }; if (isTotal) { return "Total of " + fieldName; }; return fieldName; } #endregion /// /// Initializes a new instance of the class /// /// The Field Name. /// The Measure Name. /// Indicates the "Total" element. /// Indicates the "GrandTotal" element. /// Indicates the "Measure" element. public CrossViewHeaderDescriptor(string fieldName, string measureName, bool isTotal, bool isGrandTotal, bool isMeasure) { this.isGrandTotal = isGrandTotal; this.fieldName = fieldName; this.measureName = measureName; this.isTotal = isTotal; this.isMeasure = isMeasure; } /// /// Initializes a new instance of the class /// public CrossViewHeaderDescriptor() : this("", "", false, false, false) { } } }