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 CrossView data cell. /// /// /// The class is used to define one data cell of the CrossView. /// To set visual appearance of the data cell, use the /// property. /// The collection of descriptors used to represent the CrossView data cells is stored /// in the CrossViewObject.Data.Cells property. /// public class CrossViewCellDescriptor : CrossViewDescriptor { #region Fields internal string xFieldName; internal string yFieldName; internal string measureName; internal bool isXGrandTotal; internal bool isYGrandTotal; internal bool isXTotal; internal bool isYTotal; #pragma warning disable FR0001 // Field names must be longer than 2 characters. internal int x; internal int y; #pragma warning restore FR0001 // Field names must be longer than 2 characters. #endregion #region Properties /// /// Gets a value indicating that this is the "GrandTotal" element on X axis. /// public bool IsXGrandTotal { set { isXGrandTotal = value; } get { return isXGrandTotal; } } /// /// Gets a value indicating that this is the "GrandTotal" element on Y axis. /// public bool IsYGrandTotal { set { isYGrandTotal = value; } get { return isYGrandTotal; } } /// /// Gets a value indicating that this is the "Total" element on X axis. /// public bool IsXTotal { set { isXTotal = value; } get { return isXTotal; } } /// /// Gets a value indicating that this is the "Total" element on Y axis. /// public bool IsYTotal { set { isYTotal = value; } get { return isYTotal; } } /// /// Gets the name of field in X axis. /// public string XFieldName { set { xFieldName = value; } get { return xFieldName; } } /// /// Gets the name of field in Y axis. /// public string YFieldName { set { yFieldName = value; } get { return yFieldName; } } /// /// Gets the name of measure in cube. /// public string MeasureName { set { measureName = value; } get { return measureName; } } /// /// Gets the x coordinate. /// public int X { set { x = value; } get { return x; } } /// /// Gets the y coordinate. /// public int Y { set { y = value; } get { return y; } } #endregion #region Public Methods /// public override void Assign(CrossViewDescriptor source) { base.Assign(source); CrossViewCellDescriptor src = source as CrossViewCellDescriptor; if (src != null) { isXTotal = src.isXTotal; isYTotal = src.isYTotal; isXGrandTotal = src.isXGrandTotal; isYGrandTotal = src.isYGrandTotal; xFieldName = src.xFieldName; yFieldName = src.yFieldName; measureName = src.measureName; x = src.x; y = src.y; } } /// public override void Serialize(FRWriter writer) { CrossViewCellDescriptor c = writer.DiffObject as CrossViewCellDescriptor; base.Serialize(writer); writer.ItemName = "Cell"; if (IsXTotal != c.IsXTotal) writer.WriteBool("IsXTotal", IsXTotal); if (IsYTotal != c.IsYTotal) writer.WriteBool("IsYTotal", IsYTotal); if (IsXGrandTotal != c.IsXGrandTotal) writer.WriteBool("IsXGrandTotal", IsXGrandTotal); if (IsYGrandTotal != c.IsYGrandTotal) writer.WriteBool("IsYGrandTotal", IsYGrandTotal); if (XFieldName != c.XFieldName) writer.WriteStr("XFieldName", XFieldName); if (YFieldName != c.YFieldName) writer.WriteStr("YFieldName", YFieldName); if (MeasureName != c.MeasureName) writer.WriteStr("MeasureName", MeasureName); if (X != c.X) writer.WriteInt("X", X); if (Y != c.Y) writer.WriteInt("Y", Y); } #endregion /// /// Initializes a new instance of the class /// /// The Field Name in X axis. /// The Field Name in Y axis. /// The Measure Name. /// Indicates the "XTotal" element. /// Indicates the "YTotal" element. /// Indicates the "XGrandTotal" element. /// Indicates the "YGrandTotal" element. public CrossViewCellDescriptor(string xFieldName, string yFieldName, string measureName, bool isXTotal, bool isYTotal, bool isXGrandTotal, bool isYGrandTotal) { this.isXGrandTotal = isXGrandTotal; this.isYGrandTotal = isYGrandTotal; this.measureName = measureName; if (isXGrandTotal) { this.xFieldName = ""; this.isXTotal = false; } else { this.xFieldName = xFieldName; this.isXTotal = isXTotal; } if (isYGrandTotal) { this.yFieldName = ""; this.isYTotal = false; } else { this.yFieldName = yFieldName; this.isYTotal = isYTotal; } } /// /// Initializes a new instance of the class /// public CrossViewCellDescriptor() : this("", "", "", false, false, false, false) { } } }