MyNes_src/MyNes/MLV/ManagedListViewItemsCollection.cs
2024-07-03 10:36:42 +08:00

114 lines
1.9 KiB
C#

using System.Collections.Generic;
namespace MLV;
public class ManagedListViewItemsCollection : List<ManagedListViewItem>
{
private ManagedListView owner;
public ManagedListViewItemsCollection()
{
owner = null;
}
public ManagedListViewItemsCollection(IEnumerable<ManagedListViewItem> newItems)
: base(newItems)
{
owner = null;
}
public ManagedListViewItemsCollection(ManagedListView owner)
{
this.owner = owner;
}
public ManagedListViewItemsCollection(ManagedListView owner, IEnumerable<ManagedListViewItem> newItems)
: base(newItems)
{
this.owner = owner;
}
public new void Add(ManagedListViewItem item)
{
base.Add(item);
if (owner != null)
{
owner.OnItemAdded();
}
}
public void AddNoEvent(ManagedListViewItem item)
{
base.Add(item);
}
public new void Clear()
{
base.Clear();
if (owner != null)
{
owner.OnItemsCollectionCleared();
}
}
public new bool Remove(ManagedListViewItem item)
{
bool result = base.Remove(item);
if (owner != null)
{
owner.OnItemRemoved();
}
return result;
}
public new void RemoveAt(int index)
{
base.RemoveAt(index);
if (owner != null)
{
owner.OnItemRemoved();
}
}
public new void Insert(int index, ManagedListViewItem item)
{
base.Insert(index, item);
if (owner != null)
{
owner.OnItemAdded();
}
}
public void InsertNoEvent(int index, ManagedListViewItem item)
{
base.Insert(index, item);
}
public new void Sort()
{
base.Sort();
if (owner != null)
{
owner.OnItemsCollectionSorted();
}
}
public new void Sort(IComparer<ManagedListViewItem> comparer)
{
base.Sort(comparer);
if (owner != null)
{
owner.OnItemsCollectionSorted();
}
}
public new void Sort(int index, int count, IComparer<ManagedListViewItem> comparer)
{
base.Sort(index, count, comparer);
if (owner != null)
{
owner.OnItemsCollectionSorted();
}
}
}