MapMultiPolygon

This commit is contained in:
ClemensFischer 2024-07-16 21:29:25 +02:00
parent 5b9ad68c57
commit dbd32361b5
11 changed files with 217 additions and 61 deletions

View file

@ -27,9 +27,9 @@ namespace MapControl
protected override void InsertItem(int index, IEnumerable<Location> polygon)
{
if (polygon is INotifyCollectionChanged observablePolygon)
if (polygon is INotifyCollectionChanged addedPolygon)
{
CollectionChangedEventManager.AddListener(observablePolygon, this);
CollectionChangedEventManager.AddListener(addedPolygon, this);
}
base.InsertItem(index, polygon);
@ -37,9 +37,14 @@ namespace MapControl
protected override void SetItem(int index, IEnumerable<Location> polygon)
{
if (this[index] is INotifyCollectionChanged observablePolygon)
if (this[index] is INotifyCollectionChanged removedPolygon)
{
CollectionChangedEventManager.RemoveListener(observablePolygon, this);
CollectionChangedEventManager.RemoveListener(removedPolygon, this);
}
if (polygon is INotifyCollectionChanged addedPolygon)
{
CollectionChangedEventManager.AddListener(addedPolygon, this);
}
base.SetItem(index, polygon);
@ -47,9 +52,9 @@ namespace MapControl
protected override void RemoveItem(int index)
{
if (this[index] is INotifyCollectionChanged observablePolygon)
if (this[index] is INotifyCollectionChanged removedPolygon)
{
CollectionChangedEventManager.RemoveListener(observablePolygon, this);
CollectionChangedEventManager.RemoveListener(removedPolygon, this);
}
base.RemoveItem(index);
@ -57,9 +62,9 @@ namespace MapControl
protected override void ClearItems()
{
foreach (var observablePolygon in this.OfType<INotifyCollectionChanged>())
foreach (var polygon in this.OfType<INotifyCollectionChanged>())
{
CollectionChangedEventManager.RemoveListener(observablePolygon, this);
CollectionChangedEventManager.RemoveListener(polygon, this);
}
base.ClearItems();