48 lines
842 B
C#
48 lines
842 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
public class BindingList<T> : IEnumerable<T>
|
|
{
|
|
public event Action OnListChanged;
|
|
private List<T> items = new List<T>();
|
|
|
|
public IEnumerator<T> GetEnumerator()
|
|
{
|
|
return items.GetEnumerator();
|
|
}
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
{
|
|
return GetEnumerator();
|
|
}
|
|
|
|
public void Add(T item)
|
|
{
|
|
items.Add(item);
|
|
OnListChanged?.Invoke();
|
|
}
|
|
|
|
public void Remove(T item)
|
|
{
|
|
items.Remove(item);
|
|
OnListChanged?.Invoke();
|
|
}
|
|
|
|
public void Clear()
|
|
{
|
|
items.Clear();
|
|
OnListChanged?.Invoke();
|
|
}
|
|
|
|
public T this[int index]
|
|
{
|
|
get { return items[index]; }
|
|
}
|
|
|
|
public int Count
|
|
{
|
|
get { return items.Count; }
|
|
}
|
|
}
|