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