mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-15 04:49:13 +00:00
服务器拖动排序:优化逻辑
This commit is contained in:
parent
617d5b1c86
commit
8aa3354b20
1 changed files with 39 additions and 38 deletions
|
@ -1679,56 +1679,57 @@ namespace v2rayN.Forms
|
||||||
{
|
{
|
||||||
targetIndex++;
|
targetIndex++;
|
||||||
}
|
}
|
||||||
string activeIndexId = ConfigHandler.GetDefaultServer(ref config).indexId;
|
|
||||||
|
|
||||||
|
bool isChanged = false;
|
||||||
lvServers.BeginUpdate();
|
lvServers.BeginUpdate();
|
||||||
foreach (ListViewItem listItem in lvServers.SelectedItems)
|
foreach (ListViewItem listItem in lvServers.SelectedItems)
|
||||||
{
|
{
|
||||||
if (targetIndex == listItem.Index)
|
if (targetIndex != listItem.Index)
|
||||||
{
|
{
|
||||||
targetIndex++;
|
isChanged = true;
|
||||||
continue;
|
int origIndex = listItem.Index;
|
||||||
|
bool isFocued = listItem.Focused;
|
||||||
|
|
||||||
|
// 向下移动,删除自身后,targetIndex-1;
|
||||||
|
if (origIndex < targetIndex)
|
||||||
|
{
|
||||||
|
targetIndex--;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
listItem.Remove();
|
||||||
|
lvServers.Items.Insert(targetIndex, listItem);
|
||||||
|
|
||||||
|
if (isFocued)
|
||||||
|
{
|
||||||
|
listItem.Focused = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int origIndex = listItem.Index;
|
|
||||||
bool isFocued = listItem.Focused;
|
|
||||||
|
|
||||||
// 向下移动,删除自身后,targetIndex-1;
|
|
||||||
if (origIndex < targetIndex)
|
|
||||||
{
|
|
||||||
targetIndex--;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
listItem.Remove();
|
|
||||||
lvServers.Items.Insert(targetIndex, listItem);
|
|
||||||
|
|
||||||
if (isFocued)
|
|
||||||
{
|
|
||||||
listItem.Focused = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
targetIndex++;
|
targetIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefillListViewBackColor(lvServers);
|
if (isChanged)
|
||||||
lvServers.EndUpdate();
|
|
||||||
|
|
||||||
for (int i = 0; i < lvServers.Items.Count; i++)
|
|
||||||
{
|
{
|
||||||
ListViewItem listItem = lvServers.Items[i];
|
RefillListViewBackColor(lvServers);
|
||||||
config.GetVmessItem((string)listItem.Tag).sort = i;
|
|
||||||
|
|
||||||
|
for (int i = 0; i < lvServers.Items.Count; i++)
|
||||||
|
{
|
||||||
|
ListViewItem listItem = lvServers.Items[i];
|
||||||
|
config.GetVmessItem((string)listItem.Tag).sort = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigHandler.SaveConfig(ref config, false);
|
||||||
|
|
||||||
|
|
||||||
|
lstVmess = config.vmess.Where(it => it.groupId == groupId).OrderBy(it => it.sort).ToList();
|
||||||
|
//RefreshServersView();
|
||||||
|
RefreshServersMenu();
|
||||||
|
|
||||||
|
//RefreshServers();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigHandler.SaveConfig(ref config, false);
|
lvServers.EndUpdate();
|
||||||
|
|
||||||
|
|
||||||
lstVmess = config.vmess.Where(it => it.groupId == groupId).OrderBy(it => it.sort).ToList();
|
|
||||||
//RefreshServersView();
|
|
||||||
RefreshServersMenu();
|
|
||||||
|
|
||||||
//RefreshServers();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue