mirror of
https://github.com/yaobiao131/downkyicore.git
synced 2025-08-10 00:52:31 +00:00
@@ -39,7 +39,7 @@ public static class ListHelper
|
||||
/// <param name="list"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <param name="index"></param>
|
||||
public static void InsertUnique<T>(Collection<T> list, T item, int index)
|
||||
public static void InsertUnique<T>(Collection<T> list, T item, int index, ref T currentSelection)
|
||||
{
|
||||
if (!list.Contains(item))
|
||||
{
|
||||
@@ -47,8 +47,19 @@ public static class ListHelper
|
||||
}
|
||||
else
|
||||
{
|
||||
var previousSelection = currentSelection;
|
||||
list.Remove(item);
|
||||
list.Insert(index, item);
|
||||
if (previousSelection != null && previousSelection.Equals(item))
|
||||
{
|
||||
currentSelection = previousSelection;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void InsertUnique<T>(Collection<T> list, T item, int index)
|
||||
{
|
||||
T defaultSelection = default;
|
||||
InsertUnique(list, item, index, ref defaultSelection);
|
||||
}
|
||||
}
|
||||
@@ -379,7 +379,7 @@ public class ViewDownloadSetterViewModel : BaseDialogViewModel
|
||||
// 将Directory移动到第一项
|
||||
// 如果直接在ComboBox中选择的就需要
|
||||
// 否则选中项不会在下次出现在第一项
|
||||
ListHelper.InsertUnique(DirectoryList, Directory, 0);
|
||||
ListHelper.InsertUnique(DirectoryList, Directory, 0,ref _directory);
|
||||
|
||||
// 将更新后的DirectoryList写入历史中
|
||||
SettingsManager.GetInstance().SetSaveVideoRootPath(Directory);
|
||||
|
||||
Reference in New Issue
Block a user