mirror of
https://github.com/2dust/v2rayN.git
synced 2025-08-24 03:46:55 +00:00
服务器排序:调整逻辑,适应新引入的sort字段
This commit is contained in:
parent
dc59c2adc5
commit
bf0c6791e6
1 changed files with 31 additions and 16 deletions
|
@ -282,6 +282,7 @@ namespace v2rayN.Forms
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ListViewItem lvItem = new ListViewItem(def);
|
ListViewItem lvItem = new ListViewItem(def);
|
||||||
|
lvItem.Tag = item.indexId;
|
||||||
Utils.AddSubItem(lvItem, EServerColName.configType.ToString(), ((EConfigType)item.configType).ToString());
|
Utils.AddSubItem(lvItem, EServerColName.configType.ToString(), ((EConfigType)item.configType).ToString());
|
||||||
Utils.AddSubItem(lvItem, EServerColName.remarks.ToString(), item.remarks);
|
Utils.AddSubItem(lvItem, EServerColName.remarks.ToString(), item.remarks);
|
||||||
Utils.AddSubItem(lvItem, EServerColName.address.ToString(), item.address);
|
Utils.AddSubItem(lvItem, EServerColName.address.ToString(), item.address);
|
||||||
|
@ -1678,43 +1679,57 @@ namespace v2rayN.Forms
|
||||||
{
|
{
|
||||||
targetIndex++;
|
targetIndex++;
|
||||||
}
|
}
|
||||||
string activeIndexId = config.indexId();
|
string activeIndexId = ConfigHandler.GetDefaultServer(ref config).indexId;
|
||||||
|
|
||||||
lvServers.BeginUpdate();
|
lvServers.BeginUpdate();
|
||||||
foreach (ListViewItem oldItem in lvServers.SelectedItems)
|
foreach (ListViewItem listItem in lvServers.SelectedItems)
|
||||||
{
|
{
|
||||||
if (targetIndex == oldItem.Index)
|
if (targetIndex == listItem.Index)
|
||||||
{
|
{
|
||||||
targetIndex++;
|
targetIndex++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
VmessItem oldVmess = config.vmess[oldItem.Index];
|
|
||||||
|
|
||||||
ListViewItem cloneItem = (ListViewItem)oldItem.Clone();
|
int origIndex = listItem.Index;
|
||||||
VmessItem cloneVmess = Utils.DeepCopy(oldVmess);
|
bool isFocued = listItem.Focused;
|
||||||
|
|
||||||
lvServers.Items.Insert(targetIndex, cloneItem);
|
// 向下移动,删除自身后,targetIndex-1;
|
||||||
config.vmess.Insert(targetIndex, cloneVmess);
|
if (origIndex < targetIndex)
|
||||||
|
|
||||||
cloneItem.Selected = true;
|
|
||||||
if (oldItem.Focused)
|
|
||||||
{
|
{
|
||||||
cloneItem.Focused = true;
|
targetIndex--;
|
||||||
}
|
}
|
||||||
|
|
||||||
lvServers.Items.Remove(oldItem);
|
|
||||||
config.vmess.Remove(oldVmess);
|
|
||||||
|
|
||||||
targetIndex = lvServers.Items.IndexOf(cloneItem) + 1;
|
listItem.Remove();
|
||||||
|
lvServers.Items.Insert(targetIndex, listItem);
|
||||||
|
|
||||||
|
if (isFocued)
|
||||||
|
{
|
||||||
|
listItem.Focused = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
targetIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefillListViewBackColor(lvServers);
|
RefillListViewBackColor(lvServers);
|
||||||
lvServers.EndUpdate();
|
lvServers.EndUpdate();
|
||||||
|
|
||||||
config.index = config.FindIndexId(activeIndexId);
|
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);
|
ConfigHandler.SaveConfig(ref config, false);
|
||||||
|
|
||||||
|
|
||||||
|
lstVmess = config.vmess.Where(it => it.groupId == groupId).OrderBy(it => it.sort).ToList();
|
||||||
|
//RefreshServersView();
|
||||||
RefreshServersMenu();
|
RefreshServersMenu();
|
||||||
|
|
||||||
|
//RefreshServers();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void lvServers_DragEnter(object sender, DragEventArgs e)
|
private void lvServers_DragEnter(object sender, DragEventArgs e)
|
||||||
|
|
Loading…
Reference in a new issue