/////////////////////////////////////////////////////////////////////////// // Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // // rights of fair usage, the disclaimer and warranty conditions. // /////////////////////////////////////////////////////////////////////////// using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; namespace wasSharp.Collections.Specialized { /// /// An observable collection allowing the add of a range of items. /// /// the collection type public class ExtendedObservableCollection : ObservableCollection { private bool _suppressNotification; protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e) { if (!_suppressNotification) base.OnCollectionChanged(e); } public void AddRange(IEnumerable list) { if (list == null) throw new ArgumentNullException(nameof(list)); _suppressNotification = true; foreach (var item in list) { Add(item); } _suppressNotification = false; OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } } }