Skip to content
35 changes: 35 additions & 0 deletions Source/NETworkManager.Controls/ObservableRangeCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;

namespace NETworkManager.Controls;

/// <summary>
/// <see cref="ObservableCollection{T}"/> that can replace all items at once with a single
/// <see cref="NotifyCollectionChangedAction.Reset"/> notification (instead of one notification per item).
/// Bound views (e.g. a filtered / sorted <see cref="System.ComponentModel.ICollectionView"/>) are refreshed only once,
/// which is much faster for large lists.
/// </summary>
/// <typeparam name="T">The type of the items.</typeparam>
public class ObservableRangeCollection<T> : ObservableCollection<T>
{
/// <summary>
/// Replaces all items with the given items and raises a single
/// <see cref="NotifyCollectionChangedAction.Reset"/> notification.
/// </summary>
/// <param name="items">The new items.</param>
public void ReplaceAll(IEnumerable<T> items)
{
CheckReentrancy();

Items.Clear();

foreach (var item in items)
Items.Add(item);

OnPropertyChanged(new PropertyChangedEventArgs(nameof(Count)));
OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ public static DocumentationIdentifier GetIdentifierBySettingsName(SettingsName n
SettingsName.WebConsole => GetIdentifierByApplicationName(ApplicationName.WebConsole),
SettingsName.SNMP => GetIdentifierByApplicationName(ApplicationName.SNMP),
SettingsName.SNTPLookup => GetIdentifierByApplicationName(ApplicationName.SNTPLookup),
SettingsName.Firewall => GetIdentifierByApplicationName(ApplicationName.Firewall),
SettingsName.WakeOnLAN => GetIdentifierByApplicationName(ApplicationName.WakeOnLAN),
SettingsName.RDAP => GetIdentifierByApplicationName(ApplicationName.RDAP),
SettingsName.BitCalculator => GetIdentifierByApplicationName(ApplicationName.BitCalculator),
Expand Down
195 changes: 195 additions & 0 deletions Source/NETworkManager.Localization/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading