1
0
mirror of https://github.com/chylex/Backup-Essentials.git synced 2025-08-16 23:31:43 +02:00
Files
BackupEssentials
Backup
Controls
Data
Pages
Properties
Resources
Sys
Utils
Collections
KeyEqualityComparer.cs
ObservableDictionary.cs
SafeDictionary.cs
StringDictionarySerializer.cs
IO
NativeMethods.cs
NumberSerialization.cs
Profiler.cs
ProgramArgsParser.cs
ScheduledUpdate.cs
WindowsVersion.cs
WpfExtensions.cs
App.xaml
App.xaml.cs
AppPageManager.cs
BackupEssentials.csproj
BackupReportWindow.xaml
BackupReportWindow.xaml.cs
BackupWindow.xaml
BackupWindow.xaml.cs
MainWindow.xaml
MainWindow.xaml.cs
TestingWindow.xaml
TestingWindow.xaml.cs
.gitignore
BackupEssentials.sln
LICENSE
README.md

35 lines
1.1 KiB
C#

using System.Collections.Generic;
using System.ComponentModel;
namespace BackupEssentials.Utils.Collections{
class ObservableDictionary<TKey,TValue> : Dictionary<TKey,TValue>, INotifyPropertyChanged{
public event PropertyChangedEventHandler PropertyChanged;
public bool PauseObservation = false;
public new TValue this[TKey key] {
get { return base[key]; }
set { base[key] = value; OnChanged(key); }
}
public new void Add(TKey key, TValue value){
base.Add(key,value);
OnChanged(key);
}
public void Add(KeyValuePair<TKey,TValue> item){
base.Add(item.Key,item.Value);
OnChanged(item.Key);
}
public new bool Remove(TKey key){
bool val = base.Remove(key);
if (val)OnChanged(key);
return val;
}
private void OnChanged(TKey key){
if (PropertyChanged != null && !PauseObservation)PropertyChanged(this,new PropertyChangedEventArgs(key.ToString()));
}
}
}