Skip to content
This repository has been archived by the owner on Jan 1, 2024. It is now read-only.

Commit

Permalink
Update mapping indexes for special actions list after removing an action
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryochan7 committed Sep 29, 2023
1 parent 576828f commit 15c2691
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions DS4Windows/DS4Forms/ViewModels/SpecialActionsListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ public SpecialActionsListViewModel(int deviceNum)
this.deviceNum = deviceNum;

SpecialActionIndexChanged += SpecialActionsListViewModel_SpecialActionIndexChanged;
actionCol.CollectionChanged += ActionCol_CollectionChanged;
}

private void ActionCol_CollectionChanged(object sender,
System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
{
for (int i = e.OldStartingIndex; i < actionCol.Count; i++)
{
// Replace old index with updated index
actionCol[i].Index = i;
}
}
}

private void SpecialActionsListViewModel_SpecialActionIndexChanged(object sender, EventArgs e)
Expand Down

0 comments on commit 15c2691

Please sign in to comment.