mirror of
https://github.com/tribufu/ServerManagers
synced 2026-05-06 15:17:34 +00:00
source code checkin
This commit is contained in:
parent
5f8fb2c825
commit
7e57b72e35
675 changed files with 168433 additions and 0 deletions
67
src/Plugin.Discord/Models/ProfileNameValueList.cs
Normal file
67
src/Plugin.Discord/Models/ProfileNameValueList.cs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
|
||||
namespace ServerManagerTool.Plugin.Discord
|
||||
{
|
||||
internal class ProfileNameValueList : List<ProfileNameValue>, IBindable, INotifyCollectionChanged
|
||||
{
|
||||
private bool _hasChanges = false;
|
||||
|
||||
public bool HasChanges
|
||||
{
|
||||
get => _hasChanges;
|
||||
set => _hasChanges = value;
|
||||
}
|
||||
|
||||
public bool HasAnyChanges => _hasChanges || this.Any(p => p?.HasAnyChanges ?? false);
|
||||
|
||||
public void BeginUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
public void CommitChanges()
|
||||
{
|
||||
HasChanges = false;
|
||||
|
||||
foreach (var profileName in this)
|
||||
{
|
||||
profileName.CommitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public void EndUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
#region INotifyCollectionChanged
|
||||
public event NotifyCollectionChangedEventHandler CollectionChanged;
|
||||
#endregion
|
||||
|
||||
protected void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
CollectionChanged?.Invoke(this, e);
|
||||
}
|
||||
|
||||
public void NotifyAdd(ProfileNameValue item, bool setChanged = true)
|
||||
{
|
||||
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item));
|
||||
if (setChanged)
|
||||
HasChanges = true;
|
||||
}
|
||||
|
||||
public void NotifyClear(bool setChanged = true)
|
||||
{
|
||||
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
||||
if (setChanged)
|
||||
HasChanges = true;
|
||||
}
|
||||
|
||||
public void NotifyRemove(ProfileNameValue item, int index, bool setChanged = true)
|
||||
{
|
||||
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, index));
|
||||
if (setChanged)
|
||||
HasChanges = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue