forked from izrik/FbxSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChangeNotifyList.cs
More file actions
128 lines (95 loc) · 2.53 KB
/
ChangeNotifyList.cs
File metadata and controls
128 lines (95 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
using System;
using System.Collections.Generic;
namespace FbxSharp
{
public class ChangeNotifyList<T> : IList<T>
{
public ChangeNotifyList(List<T> list=null)
{
if (list == null)
list = new List<T>();
this.list = list;
}
readonly List<T> list;
public event EventHandler CollectionChanged;
protected void OnCollectionChanged()
{
if (CollectionChanged != null)
{
CollectionChanged(this, EventArgs.Empty);
}
}
#region IList implementation
public int IndexOf(T item)
{
return list.IndexOf(item);
}
public void Insert(int index, T item)
{
list.Insert(index, item);
OnCollectionChanged();
}
public void RemoveAt(int index)
{
list.RemoveAt(index);
OnCollectionChanged();
}
public T this[int index] {
get { return list[index]; }
set
{
list[index] = value;
OnCollectionChanged();
}
}
#endregion
#region ICollection implementation
public void Add(T item)
{
list.Add(item);
OnCollectionChanged();
}
public void Clear()
{
list.Clear();
OnCollectionChanged();
}
public bool Contains(T item)
{
return list.Contains(item);
}
public void CopyTo(T[] array, int arrayIndex)
{
list.CopyTo(array, arrayIndex);
}
public bool Remove(T item)
{
var r = list.Remove(item);
OnCollectionChanged();
return r;
}
public int Count {
get { return list.Count; }
}
public bool IsReadOnly {
get { return ((IList<T>)list).IsReadOnly; }
}
#endregion
#region IEnumerable implementation
public IEnumerator<T> GetEnumerator()
{
return list.GetEnumerator();
}
#endregion
#region IEnumerable implementation
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return ((System.Collections.IEnumerable)list).GetEnumerator();
}
#endregion
public int FindIndex(Predicate<T> match)
{
return list.FindIndex(match);
}
}
}