CubeSourceBase.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. using System;
  2. using System.ComponentModel;
  3. using FastReport.Utils;
  4. using FastReport.CrossView;
  5. using System.Drawing.Design;
  6. namespace FastReport.Data
  7. {
  8. /// <summary>
  9. /// Base class for all CubeSources such as <see cref="SliceCubeSource"/>.
  10. /// </summary>
  11. [TypeConverter(typeof(FastReport.TypeConverters.CubeSourceConverter))]
  12. [Editor("FastReport.TypeEditors.CubeSourceEditor, FastReport", typeof(UITypeEditor))]
  13. public abstract class CubeSourceBase : DataComponentBase
  14. {
  15. #region Fields
  16. #endregion
  17. #region Properties
  18. /// <summary>
  19. ///
  20. /// </summary>
  21. public int XAxisFieldsCount { get { return CubeLink != null ? CubeLink.XAxisFieldsCount : 0; } }
  22. /// <summary>
  23. ///
  24. /// </summary>
  25. public int YAxisFieldsCount { get { return CubeLink != null ? CubeLink.YAxisFieldsCount : 0; } }
  26. /// <summary>
  27. ///
  28. /// </summary>
  29. public int MeasuresCount { get { return CubeLink != null ? CubeLink.MeasuresCount : 0; } }
  30. /// <summary>
  31. ///
  32. /// </summary>
  33. public int MeasuresLevel { get { return CubeLink != null ? CubeLink.MeasuresLevel : 0; } }
  34. /// <summary>
  35. ///
  36. /// </summary>
  37. public bool MeasuresInXAxis { get { return CubeLink != null ? CubeLink.MeasuresInXAxis : false; } }
  38. /// <summary>
  39. ///
  40. /// </summary>
  41. public bool MeasuresInYAxis { get { return CubeLink != null ? CubeLink.MeasuresInYAxis : false; } }
  42. /// <summary>
  43. ///
  44. /// </summary>
  45. public int DataColumnCount { get { return CubeLink != null ? CubeLink.DataColumnCount : 0; } }
  46. /// <summary>
  47. ///
  48. /// </summary>
  49. public int DataRowCount { get { return CubeLink != null ? CubeLink.DataRowCount : 0; } }
  50. /// <summary>
  51. ///
  52. /// </summary>
  53. public bool SourceAssigned { get { return CubeLink != null; } }
  54. /// <summary>
  55. ///
  56. /// </summary>
  57. public event EventHandler OnChanged;
  58. /// <summary>
  59. ///
  60. /// </summary>
  61. public IBaseCubeLink CubeLink { get { return Reference as IBaseCubeLink; } }
  62. #endregion
  63. #region Private Methods
  64. #endregion
  65. #region Protected Methods
  66. #endregion
  67. #region Public Methods
  68. /// <summary>
  69. ///
  70. /// </summary>
  71. public CrossViewMeasureCell GetMeasureCell(int colIndex, int rowIndex)
  72. {
  73. if (CubeLink != null)
  74. return CubeLink.GetMeasureCell(colIndex, rowIndex);
  75. else
  76. return new CrossViewMeasureCell();
  77. }
  78. /// <summary>
  79. ///
  80. /// </summary>
  81. public void TraverseXAxis(CrossViewAxisDrawCellHandler crossViewAxisDrawCellHandler)
  82. {
  83. if (CubeLink != null)
  84. {
  85. CubeLink.TraverseXAxis(crossViewAxisDrawCellHandler);
  86. }
  87. }
  88. /// <summary>
  89. ///
  90. /// </summary>
  91. public void TraverseYAxis(CrossViewAxisDrawCellHandler crossViewAxisDrawCellHandler)
  92. {
  93. if (CubeLink != null)
  94. {
  95. CubeLink.TraverseYAxis(crossViewAxisDrawCellHandler);
  96. }
  97. }
  98. /// <summary>
  99. ///
  100. /// </summary>
  101. public string GetXAxisFieldName(int fieldIndex)
  102. {
  103. if (CubeLink != null)
  104. {
  105. return CubeLink.GetXAxisFieldName(fieldIndex);
  106. }
  107. else
  108. return "";
  109. }
  110. /// <summary>
  111. ///
  112. /// </summary>
  113. public string GetYAxisFieldName(int fieldIndex)
  114. {
  115. if (CubeLink != null)
  116. {
  117. return CubeLink.GetYAxisFieldName(fieldIndex);
  118. }
  119. else
  120. return "";
  121. }
  122. /// <summary>
  123. ///
  124. /// </summary>
  125. public string GetMeasureName(int measureIndex)
  126. {
  127. if (CubeLink != null)
  128. {
  129. return CubeLink.GetMeasureName(measureIndex);
  130. }
  131. else
  132. return "";
  133. }
  134. /// <inheritdoc/>
  135. public override void Serialize(FRWriter writer)
  136. {
  137. base.Serialize(writer);
  138. }
  139. /// <inheritdoc/>
  140. public override void Deserialize(FRReader reader)
  141. {
  142. base.Deserialize(reader);
  143. }
  144. /// <summary>
  145. ///
  146. /// </summary>
  147. public void Changed()
  148. {
  149. if (OnChanged != null)
  150. OnChanged(this, new EventArgs());
  151. }
  152. #endregion
  153. /// <summary>
  154. /// Initializes a new instance of the <see cref="CubeSourceBase"/> class with default settings.
  155. /// </summary>
  156. public CubeSourceBase()
  157. {
  158. SetFlags(Flags.HasGlobalName, true);
  159. }
  160. }
  161. }