using System;
using System.Collections.Generic;
using Chernobyl.Collections.Generic.Event;
using Chernobyl.Interface.Tool;
using Chernobyl.Mathematics.Mechanics;
namespace Chernobyl.Interface.Collections
{
///
/// An interface that implements and renders s.
/// This class extends the class and adds
/// the ability to add items to, remove items from, and clear items from the
/// view.
///
/// The type that is to be held in the
/// .
public class CollectionListView : EnumerableListView, ICollection
{
///
/// Initializes a new instance of the class.
///
/// The instance that gives out services for use
/// by this type and takes services from this type for use by other
/// systems.
/// The that is to
/// be rendered on screen.
public CollectionListView(IEventCollection services, ICollection collection)
: this(services, collection, null)
{ }
///
/// Initializes a new instance of the class.
///
/// The instance that gives out services for use
/// by this type and takes services from this type for use by other
/// systems.
/// The that is to
/// be rendered on screen.
/// The method that determines when items in
/// the list can be selected or null if the default
/// should be used
/// (The default value is given by the field
/// ). Several
/// methods are available in the
/// struct
/// or you can use your own. For performance reasons, if you don't need
/// an item to be selected, you should use
/// .
public CollectionListView(IEventCollection services, ICollection collection, SelectionModeFunc selectionMode)
: this(services, collection, selectionMode, null)
{ }
///
/// Initializes a new instance of the class.
///
/// The instance that gives out services for use
/// by this type and takes services from this type for use by other
/// systems.
/// The that is to
/// be rendered on screen.
/// The that will be used to
/// interact with the list or null if
/// should be used.
/// The method that determines when items in
/// the list can be selected or null if the default
/// should be used
/// (The default value is given by the field
/// ). Several
/// methods are available in the
/// struct
/// or you can use your own. For performance reasons, if you don't need
/// an item to be selected, you should use
/// .
public CollectionListView(IEventCollection services, ICollection collection, SelectionModeFunc selectionMode, IButton button)
: base(services, collection, selectionMode, button)
{
Collection = collection;
}
///
/// Adds an item to the .
///
/// The object to add to the .
///
/// The
/// is read-only.
public void Add(T item)
{
Collection.Add(item);
}
///
/// Removes all items from the .
///
/// The
/// is read-only.
public void Clear()
{
Collection.Clear();
}
///
/// Determines whether the contains a
/// specific value.
///
/// The object to locate in the
/// .
///
/// true if is found in the
/// ; otherwise, false.
///
public bool Contains(T item)
{
return Collection.Contains(item);
}
///
/// Copies the elements of the to an
/// , starting at a particular
/// index.
///
/// The one-dimensional that is
/// the destination of the elements copied from .
/// The must have zero-based indexing.
/// The zero-based index in
/// at which copying begins.
/// is
/// null.
///
/// is less than 0.
/// is
/// multidimensional, or is equal to or
/// greater than the length of , or the number
/// of elements in the source is greater
/// than the available space from to the
/// end of the destination , or type
/// cannot be cast automatically to the type of the
/// destination .
public void CopyTo(T[] array, int arrayIndex)
{
Collection.CopyTo(array, arrayIndex);
}
///
/// Gets the number of elements contained in the .
///
///
/// The number of elements contained in the
/// .
public int Count
{
get { return Collection.Count; }
}
///
/// Gets a value indicating whether the is
/// read-only.
///
///
/// true if the is read-only;
/// otherwise, false.
public bool IsReadOnly
{
get { return Collection.IsReadOnly; }
}
///
/// Removes the first occurrence of a specific object from the
/// .
///
/// The object to remove from the
/// .
///
/// true if was successfully removed from the
/// ; otherwise, false. This method also
/// returns false if is not found in the original
/// .
///
/// The
/// is read-only.
public bool Remove(T item)
{
return Collection.Remove(item);
}
///
/// The that is viewable in the interface list.
///
ICollection Collection { get; set; }
}
}