CrossViewCells.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Collections;
  5. using FastReport.Utils;
  6. namespace FastReport.CrossView
  7. {
  8. /// <summary>
  9. /// Represents a collection of CrossView data descriptors used in the <see cref="CrossViewObject"/>.
  10. /// </summary>
  11. public class CrossViewCells : CollectionBase, IFRSerializable
  12. {
  13. private string name;
  14. /// <summary>
  15. /// Gets or sets the element at the specified index.
  16. /// </summary>
  17. /// <param name="index">Index of an element.</param>
  18. /// <returns>The element at the specified index.</returns>
  19. public CrossViewCellDescriptor this[int index]
  20. {
  21. get { return List[index] as CrossViewCellDescriptor; }
  22. set { List[index] = value; }
  23. }
  24. internal string Name
  25. {
  26. get { return name; }
  27. set { name = value; }
  28. }
  29. /// <summary>
  30. /// Adds the specified descriptors to the end of this collection.
  31. /// </summary>
  32. /// <param name="range">Array of descriptors to add.</param>
  33. internal void AddRange(CrossViewCellDescriptor[] range)
  34. {
  35. foreach (CrossViewCellDescriptor s in range)
  36. {
  37. Add(s);
  38. }
  39. }
  40. /// <summary>
  41. /// Adds a descriptor to the end of this collection.
  42. /// </summary>
  43. /// <param name="value">Descriptor to add.</param>
  44. /// <returns>Index of the added descriptor.</returns>
  45. internal int Add(CrossViewCellDescriptor value)
  46. {
  47. return List.Add(value);
  48. }
  49. /// <summary>
  50. /// Inserts a descriptor into this collection at the specified index.
  51. /// </summary>
  52. /// <param name="index">The zero-based index at which value should be inserted.</param>
  53. /// <param name="value">The descriptor to insert.</param>
  54. internal void Insert(int index, CrossViewCellDescriptor value)
  55. {
  56. List.Insert(index, value);
  57. }
  58. /// <summary>
  59. /// Removes the specified descriptor from the collection.
  60. /// </summary>
  61. /// <param name="value">Descriptor to remove.</param>
  62. internal void Remove(CrossViewCellDescriptor value)
  63. {
  64. int i = IndexOf(value);
  65. if (i != -1)
  66. List.RemoveAt(i);
  67. }
  68. /// <summary>
  69. /// Returns the zero-based index of the first occurrence of a descriptor.
  70. /// </summary>
  71. /// <param name="value">The descriptor to locate in the collection.</param>
  72. /// <returns>The zero-based index of the first occurrence of descriptor within
  73. /// the entire collection, if found; otherwise, -1.</returns>
  74. internal int IndexOf(CrossViewCellDescriptor value)
  75. {
  76. return List.IndexOf(value);
  77. }
  78. /// <summary>
  79. /// Determines whether a descriptor is in the collection.
  80. /// </summary>
  81. /// <param name="value">The descriptor to locate in the collection.</param>
  82. /// <returns><b>true</b> if descriptor is found in the collection; otherwise, <b>false</b>.</returns>
  83. internal bool Contains(CrossViewCellDescriptor value)
  84. {
  85. return List.Contains(value);
  86. }
  87. /// <summary>
  88. /// Copies the elements of this collection to a new array.
  89. /// </summary>
  90. /// <returns>An array containing copies of this collection elements. </returns>
  91. internal CrossViewCellDescriptor[] ToArray()
  92. {
  93. CrossViewCellDescriptor[] result = new CrossViewCellDescriptor[Count];
  94. for (int i = 0; i < Count; i++)
  95. {
  96. result[i] = this[i];
  97. }
  98. return result;
  99. }
  100. /// <inheritdoc/>
  101. public void Serialize(FRWriter writer)
  102. {
  103. writer.ItemName = Name;
  104. foreach (CrossViewCellDescriptor d in this)
  105. {
  106. writer.Write(d);
  107. }
  108. }
  109. /// <inheritdoc/>
  110. public void Deserialize(FRReader reader)
  111. {
  112. Clear();
  113. while (reader.NextItem())
  114. {
  115. CrossViewCellDescriptor d = new CrossViewCellDescriptor();
  116. reader.Read(d);
  117. Add(d);
  118. }
  119. }
  120. /// <summary>
  121. ///
  122. /// </summary>
  123. public CrossViewCells()
  124. {
  125. }
  126. }
  127. }