1
0
mirror of https://github.com/fadden/6502bench.git synced 2025-02-08 20:30:47 +00:00

Recalculate list indices after adding or removing lines

Minor display list bug that presented itself when a 3-line note
was deleted.
This commit is contained in:
Andy McFadden 2019-07-14 14:41:46 -07:00
parent 12874d32ba
commit 380c56a4ef
2 changed files with 14 additions and 1 deletions

View File

@ -315,6 +315,7 @@ namespace SourceGenWPF {
if (oldCount != newCount) {
SelectedIndices = new DisplayListSelection(mList.Count);
RecalculateListIndices();
}
OnPropertyChanged(CountString);
@ -322,6 +323,18 @@ namespace SourceGenWPF {
OnCollectionReset();
}
/// <summary>
/// Recalculates the list index fields after lines are added or removed.
/// </summary>
private void RecalculateListIndices() {
Debug.WriteLine("Recalculating list indices");
for (int i = 0; i < mList.Count; i++) {
if (mList[i] != null) {
mList[i].ListIndex = i;
}
}
}
/// <summary>
/// List elements. Instances are immutable.
/// </summary>

View File

@ -2267,7 +2267,7 @@ namespace SourceGenWPF {
/// is selected.</param>
public SelectionState UpdateSelectionState() {
int selCount = mMainWin.CodeListView_GetSelectionCount();
Debug.WriteLine("SelectionChanged, selCount=" + selCount);
Debug.WriteLine("SelectionChanged: selCount=" + selCount);
SelectionState state = new SelectionState();