using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using FastReport.Utils;
namespace FastReport
{
///
/// Represents a collection of highlight conditions used in the property
/// of the .
///
public class ConditionCollection : CollectionBase, IFRSerializable
{
///
/// Gets or sets the element at the specified index.
///
/// Index of an element.
/// The element at the specified index.
public HighlightCondition this[int index]
{
get { return List[index] as HighlightCondition; }
set { List[index] = value; }
}
///
/// Adds the specified elements to the end of this collection.
///
/// Array of elements to add.
public void AddRange(HighlightCondition[] range)
{
foreach (HighlightCondition t in range)
{
Add(t);
}
}
///
/// Adds an object to the end of this collection.
///
/// Object to add.
/// Index of the added object.
public int Add(HighlightCondition value)
{
if (value == null)
return -1;
return List.Add(value);
}
///
/// Inserts an object into this collection at the specified index.
///
/// The zero-based index at which value should be inserted.
/// The object to insert.
public void Insert(int index, HighlightCondition value)
{
if (value != null)
List.Insert(index, value);
}
///
/// Removes the specified object from the collection.
///
/// Object to remove.
public void Remove(HighlightCondition value)
{
if (Contains(value))
List.Remove(value);
}
///
/// Returns the zero-based index of the first occurrence of an object.
///
/// The object to locate in the collection.
/// The zero-based index of the first occurrence of value within the entire collection, if found;
/// otherwise, -1.
public int IndexOf(HighlightCondition value)
{
return List.IndexOf(value);
}
///
/// Determines whether an element is in the collection.
///
/// The object to locate in the collection.
/// true if object is found in the collection; otherwise, false.
public bool Contains(HighlightCondition value)
{
return List.Contains(value);
}
///
public void Serialize(FRWriter writer)
{
writer.ItemName = "Highlight";
foreach (HighlightCondition c in this)
{
writer.Write(c);
}
}
///
public void Deserialize(FRReader reader)
{
Clear();
while (reader.NextItem())
{
HighlightCondition c = new HighlightCondition();
reader.Read(c);
Add(c);
}
}
///
/// Copies conditions from another collection.
///
/// Collection to copy from.
public void Assign(ConditionCollection collection)
{
Clear();
foreach (HighlightCondition condition in collection)
{
Add(condition.Clone());
}
}
///
public override bool Equals(object obj)
{
ConditionCollection collection = obj as ConditionCollection;
if (collection == null || Count != collection.Count)
return false;
for (int i = 0; i < Count; i++)
{
if (!this[i].Equals(collection[i]))
return false;
}
return true;
}
///
public override int GetHashCode()
{
return base.GetHashCode();
}
}
}