using System;
using System.Collections.Generic;
using Chernobyl.Mathematics.Movement;
namespace Chernobyl.Mathematics.Geometry
{
///
/// An and that holds
/// instances. This class works like
/// in that it can expand and contract to
/// fit a collection of other instances inside of
/// it.
///
public class ShapeList : ShapeCollection, IList
{
///
/// Initializes a new instance of the
/// class.
///
public ShapeList()
: this(0)
{ }
///
/// Initializes a new instance of the
/// class.
///
/// The number of elements that the new list can
/// initially store.
public ShapeList(int capacity)
: this(new List(capacity))
{ }
///
/// Initializes a new instance of the class.
///
/// The list to store s
/// in or null if the default should be used.
public ShapeList(IList geometries)
: this(geometries, null)
{ }
///
/// Initializes a new instance of the class.
///
/// The list to store s
/// in or null if the default should be used.
/// The list to use for the
/// list or null if the default
/// should be used..
public ShapeList(ICollection geometries, IList childTransformList)
: base(geometries, childTransformList)
{
GeometryList = (IList) Geometries;
}
///
/// Determines the index of a specific item in the .
///
/// The object to locate in the .
///
/// The index of if found in the list; otherwise, -1.
///
public int IndexOf(IShape item)
{
return GeometryList.IndexOf(item);
}
///
/// Inserts an item to the at the specified index.
///
/// The zero-based index at which
/// should be inserted.
/// The object to insert into the
/// .
///
/// is not a valid index in the .
/// The
/// is read-only.
public void Insert(int index, IShape item)
{
item.TransformDirtied += Geometry2DTransformDirtied;
IsUpdateNeeded = true;
GeometryList.Insert(index, item);
}
///
/// Removes the item at the specified index.
///
/// The zero-based index of the item to remove.
///
/// is not a valid index in the .
/// The
/// is read-only.
public void RemoveAt(int index)
{
if(index > 0 && index < Count)
{
GeometryList[index].TransformDirtied -= Geometry2DTransformDirtied;
IsUpdateNeeded = true;
GeometryList.RemoveAt(index);
}
}
///
/// Gets or sets the at the specified index.
///
public IShape this[int index]
{
get
{
return GeometryList[index];
}
set
{
GeometryList[index].TransformDirtied -= Geometry2DTransformDirtied;
GeometryList[index] = value;
value.TransformDirtied += Geometry2DTransformDirtied;
IsUpdateNeeded = true;
}
}
///
/// The collection casted
/// to an
///
IList GeometryList { get; set; }
}
}