FastReport

Форк
0
140 строк · 4.4 Кб
1
using System;
2
using System.Collections.Generic;
3
using System.Text;
4
using System.Collections;
5
using FastReport.Utils;
6

7
namespace FastReport.CrossView
8
{
9
    /// <summary>
10
    /// Represents a collection of CrossView data descriptors used in the <see cref="CrossViewObject"/>.
11
    /// </summary>
12
    public class CrossViewCells : CollectionBase, IFRSerializable
13
    {
14
        private 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>
21
        public CrossViewCellDescriptor this[int index]
22
        {
23
            get { return List[index] as CrossViewCellDescriptor; }
24
            set { List[index] = value; }
25
        }
26

27
        internal string Name
28
        {
29
            get { return name; }
30
            set { 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>
37
        internal void AddRange(CrossViewCellDescriptor[] range)
38
        {
39
            foreach (CrossViewCellDescriptor s in range)
40
            {
41
                Add(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>
50
        internal int Add(CrossViewCellDescriptor value)
51
        {
52
            return 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>
60
        internal void Insert(int index, CrossViewCellDescriptor value)
61
        {
62
            List.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>
69
        internal void Remove(CrossViewCellDescriptor value)
70
        {
71
            int i = IndexOf(value);
72
            if (i != -1)
73
                List.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>
82
        internal int IndexOf(CrossViewCellDescriptor value)
83
        {
84
            return 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>
92
        internal bool Contains(CrossViewCellDescriptor value)
93
        {
94
            return 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>
101
        internal CrossViewCellDescriptor[] ToArray()
102
        {
103
            CrossViewCellDescriptor[] result = new CrossViewCellDescriptor[Count];
104
            for (int i = 0; i < Count; i++)
105
            {
106
                result[i] = this[i];
107
            }
108
            return result;
109
        }
110

111
        /// <inheritdoc/>
112
        public void Serialize(FRWriter writer)
113
        {
114
            writer.ItemName = Name;
115
            foreach (CrossViewCellDescriptor d in this)
116
            {
117
                writer.Write(d);
118
            }
119
        }
120

121
        /// <inheritdoc/>
122
        public void Deserialize(FRReader reader)
123
        {
124
            Clear();
125
            while (reader.NextItem())
126
            {
127
                CrossViewCellDescriptor d = new CrossViewCellDescriptor();
128
                reader.Read(d);
129
                Add(d);
130
            }
131
        }
132

133
        /// <summary>
134
        ///
135
        /// </summary>
136
        public CrossViewCells()
137
        {
138
        }
139
    }
140
}
141

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.