using System; using System.Collections.Generic; namespace DPumpHydr.WinFrmUI.WenSkin { public class WenList : List { public event EventHandler> ItemAdded; public event EventHandler> ItemRemoved; protected virtual void OnItemAdded(T e, int index) { ItemAdded?.Invoke(this, new WenListEventArgs(e, index)); } protected virtual void OnItemRemoved(T e, int index) { ItemRemoved?.Invoke(this, new WenListEventArgs(e, index)); } public new void Add(T item) { base.Add(item); OnItemAdded(item, base.Count - 1); } public new void AddRange(IEnumerable collection) { foreach (var item in collection) { Add(item); } } public new bool Remove(T item) { int index = base.IndexOf(item); OnItemRemoved(item, index); return base.Remove(item); } public new void RemoveAt(int index) { T t = base[index]; OnItemRemoved(t, index); base.RemoveAt(index); } } public class WenListEventArgs : EventArgs { public WenListEventArgs(T item, int index) { this.Item = item; this.Index = index; } public int Index { get; set; } public T Item { get; set; } } }