mirror of
https://github.com/hawkeye-stan/msfs-popout-panel-manager.git
synced 2024-11-30 17:50:09 +00:00
51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Collections.ObjectModel;
|
|||
|
using System.Collections.Specialized;
|
|||
|
|
|||
|
namespace MSFSPopoutPanelManager.Shared
|
|||
|
{
|
|||
|
public class ObservableRangeCollection<T> : ObservableCollection<T>
|
|||
|
{
|
|||
|
public ObservableRangeCollection()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public ObservableRangeCollection(IEnumerable<T> collection) : base(collection)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public void AddRange(IEnumerable<T> collection)
|
|||
|
{
|
|||
|
if (collection == null) throw new ArgumentNullException(nameof(collection));
|
|||
|
|
|||
|
foreach (var i in collection) Items.Add(i);
|
|||
|
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
|||
|
}
|
|||
|
|
|||
|
public void RemoveRange(IEnumerable<T> collection)
|
|||
|
{
|
|||
|
if (collection == null) throw new ArgumentNullException(nameof(collection));
|
|||
|
|
|||
|
foreach (var i in collection) Items.Remove(i);
|
|||
|
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
|||
|
}
|
|||
|
|
|||
|
public void Replace(T item)
|
|||
|
{
|
|||
|
ReplaceRange(new [] { item });
|
|||
|
}
|
|||
|
|
|||
|
public void ReplaceRange(IEnumerable<T> collection)
|
|||
|
{
|
|||
|
if (collection == null) throw new ArgumentNullException(nameof(collection));
|
|||
|
|
|||
|
Items.Clear();
|
|||
|
foreach (var i in collection) Items.Add(i);
|
|||
|
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|