1
0
Fork 0
mirror of https://github.com/hawkeye-stan/msfs-popout-panel-manager.git synced 2024-11-22 05:40:11 +00:00
msfs-popout-panel-manager/DomainModel/DynamicLod/ObservableLodConfigLinkedList.cs

73 lines
2.4 KiB
C#
Raw Normal View History

2024-02-28 02:44:21 +00:00
using System.Collections.Generic;
using System.Collections.Specialized;
namespace MSFSPopoutPanelManager.DomainModel.DynamicLod
{
public class ObservableLodConfigLinkedList : LinkedList<LodConfig>, INotifyCollectionChanged
{
public event NotifyCollectionChangedEventHandler CollectionChanged;
public void OnNotifyCollectionChanged(NotifyCollectionChangedAction action, LodConfig item)
{
if (CollectionChanged == null)
return;
switch (action)
{
case NotifyCollectionChangedAction.Add:
case NotifyCollectionChangedAction.Remove:
case NotifyCollectionChangedAction.Reset:
CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
break;
}
}
public new void AddFirst(LodConfig item)
{
base.AddFirst(item);
OnNotifyCollectionChanged(NotifyCollectionChangedAction.Add, item);
}
public new void AddLast(LodConfig item)
{
base.AddLast(item);
OnNotifyCollectionChanged(NotifyCollectionChangedAction.Add, item);
}
public new void AddBefore(LinkedListNode<LodConfig> node, LinkedListNode<LodConfig> newNode)
{
base.AddBefore(node, newNode);
OnNotifyCollectionChanged(NotifyCollectionChangedAction.Add, newNode.Value);
}
public new void AddAfter(LinkedListNode<LodConfig> node, LinkedListNode<LodConfig> newNode)
{
base.AddAfter(node, newNode);
OnNotifyCollectionChanged(NotifyCollectionChangedAction.Add, newNode.Value);
}
public new void Remove(LodConfig item)
{
base.Remove(item);
OnNotifyCollectionChanged(NotifyCollectionChangedAction.Remove, item);
}
public new void RemoveFirst()
{
if (First == null)
return;
base.RemoveFirst();
OnNotifyCollectionChanged(NotifyCollectionChangedAction.Remove, First.Value);
}
public new void RemoveLast()
{
if (Last == null)
return;
base.RemoveLast();
OnNotifyCollectionChanged(NotifyCollectionChangedAction.Remove, Last.Value);
}
}
}