Add `WatchList.InsertRange` and use when duplicating rows in RAM Watch
This commit is contained in:
parent
4d4887ee31
commit
ca8a183f38
|
@ -143,6 +143,21 @@ namespace BizHawk.Client.Common
|
|||
Changes = true;
|
||||
}
|
||||
|
||||
/// <param name="index">
|
||||
/// <c>0</c> to prepend, <see cref="Count"/> to append, anything in-between to insert there
|
||||
/// (the first elem of <paramref name="collection"/> will end up at <paramref name="index"/>)
|
||||
/// </param>
|
||||
public void InsertRange(int index, IEnumerable<Watch> collection)
|
||||
{
|
||||
#if NET6_0
|
||||
if (collection.TryGetNonEnumeratedCount(out var n) && n is 0) return;
|
||||
#else
|
||||
if (collection is ICollection<Watch> hasCount && hasCount.Count is 0) return;
|
||||
#endif
|
||||
_watchList.InsertRange(index, collection);
|
||||
Changes = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes item at the specified index
|
||||
/// </summary>
|
||||
|
|
|
@ -411,7 +411,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (duplicate)
|
||||
{
|
||||
_watches.AddRange(we.Watches);
|
||||
_watches.InsertRange(WatchListView.SelectionEndIndex!.Value + 1, we.Watches); //TODO should be able to reduce the number of enumerations of selected rows if necessary --yoshi
|
||||
WatchListView.RowCount = _watches.Count;
|
||||
UpdateWatchCount();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue