mirror of
https://github.com/2dust/v2rayN.git
synced 2025-04-19 13:42:24 +00:00
Jump to the selected item when refreshing the server list
https://github.com/2dust/v2rayN/issues/6800
This commit is contained in:
parent
6d6894591c
commit
a18ae5582b
3 changed files with 64 additions and 16 deletions
|
@ -247,7 +247,10 @@ namespace v2rayN.Desktop.Views
|
|||
|
||||
case EViewAction.AddServerViaClipboard:
|
||||
var clipboardData = await AvaUtils.GetClipboardData(this);
|
||||
ViewModel?.AddServerViaClipboardAsync(clipboardData);
|
||||
if (ViewModel != null)
|
||||
{
|
||||
await ViewModel.AddServerViaClipboardAsync(clipboardData);
|
||||
}
|
||||
break;
|
||||
|
||||
case EViewAction.AdjustMainLvColWidth:
|
||||
|
@ -294,7 +297,10 @@ namespace v2rayN.Desktop.Views
|
|||
break;
|
||||
|
||||
case WindowCloseReason.ApplicationShutdown or WindowCloseReason.OSShutdown:
|
||||
await ViewModel?.MyAppExitAsync(true);
|
||||
if (ViewModel != null)
|
||||
{
|
||||
await ViewModel.MyAppExitAsync(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -309,7 +315,10 @@ namespace v2rayN.Desktop.Views
|
|||
{
|
||||
case Key.V:
|
||||
var clipboardData = await AvaUtils.GetClipboardData(this);
|
||||
ViewModel?.AddServerViaClipboardAsync(clipboardData);
|
||||
if (ViewModel != null)
|
||||
{
|
||||
await ViewModel.AddServerViaClipboardAsync(clipboardData);
|
||||
}
|
||||
break;
|
||||
|
||||
case Key.S:
|
||||
|
@ -358,7 +367,11 @@ namespace v2rayN.Desktop.Views
|
|||
{
|
||||
return;
|
||||
}
|
||||
await ViewModel?.ScanImageResult(fileName);
|
||||
|
||||
if (ViewModel != null)
|
||||
{
|
||||
await ViewModel.ScanImageResult(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
private void MenuCheckUpdate_Click(object? sender, RoutedEventArgs e)
|
||||
|
@ -382,8 +395,10 @@ namespace v2rayN.Desktop.Views
|
|||
|
||||
_blCloseByUser = true;
|
||||
StorageUI();
|
||||
|
||||
await ViewModel?.MyAppExitAsync(false);
|
||||
if (ViewModel != null)
|
||||
{
|
||||
await ViewModel.MyAppExitAsync(false);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Event
|
||||
|
|
|
@ -102,11 +102,16 @@ namespace v2rayN.Desktop.Views
|
|||
private async void LstProfiles_Sorting(object? sender, DataGridColumnEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
await ViewModel?.SortServer(e.Column.Tag.ToString());
|
||||
|
||||
if (ViewModel != null && e.Column?.Tag?.ToString() != null)
|
||||
{
|
||||
await ViewModel.SortServer(e.Column.Tag.ToString());
|
||||
}
|
||||
|
||||
e.Handled = false;
|
||||
}
|
||||
|
||||
//#region Event
|
||||
#region Event
|
||||
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
{
|
||||
|
@ -179,7 +184,9 @@ namespace v2rayN.Desktop.Views
|
|||
|
||||
case EViewAction.DispatcherRefreshServersBiz:
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
ViewModel?.RefreshServersBiz(),
|
||||
{
|
||||
_ = RefreshServersBiz();
|
||||
},
|
||||
DispatcherPriority.Default);
|
||||
break;
|
||||
}
|
||||
|
@ -198,6 +205,19 @@ namespace v2rayN.Desktop.Views
|
|||
await DialogHost.Show(dialog);
|
||||
}
|
||||
|
||||
public async Task RefreshServersBiz()
|
||||
{
|
||||
if (ViewModel != null)
|
||||
{
|
||||
await ViewModel.RefreshServersBiz();
|
||||
}
|
||||
|
||||
if (lstProfiles.SelectedIndex > 0)
|
||||
{
|
||||
lstProfiles.ScrollIntoView(lstProfiles.SelectedItem, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void lstProfiles_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
ViewModel.SelectedProfiles = lstProfiles.SelectedItems.Cast<ProfileItemModel>().ToList();
|
||||
|
@ -333,9 +353,9 @@ namespace v2rayN.Desktop.Views
|
|||
}
|
||||
}
|
||||
|
||||
//#endregion Event
|
||||
#endregion Event
|
||||
|
||||
//#region UI
|
||||
#region UI
|
||||
|
||||
private void RestoreUI()
|
||||
{
|
||||
|
@ -388,9 +408,9 @@ namespace v2rayN.Desktop.Views
|
|||
_config.UiItem.MainColumnItem = lvColumnItem;
|
||||
}
|
||||
|
||||
//#endregion UI
|
||||
#endregion UI
|
||||
|
||||
//#region Drag and Drop
|
||||
#region Drag and Drop
|
||||
|
||||
//private Point startPoint = new();
|
||||
//private int startIndex = -1;
|
||||
|
@ -480,6 +500,6 @@ namespace v2rayN.Desktop.Views
|
|||
// }
|
||||
//}
|
||||
|
||||
//#endregion Drag and Drop
|
||||
#endregion Drag and Drop
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ namespace v2rayN.Views
|
|||
case EViewAction.DispatcherRefreshServersBiz:
|
||||
Application.Current?.Dispatcher.Invoke((() =>
|
||||
{
|
||||
ViewModel?.RefreshServersBiz();
|
||||
_ = RefreshServersBiz();
|
||||
}), DispatcherPriority.Normal);
|
||||
break;
|
||||
}
|
||||
|
@ -186,6 +186,19 @@ namespace v2rayN.Views
|
|||
await DialogHost.Show(dialog, "RootDialog");
|
||||
}
|
||||
|
||||
public async Task RefreshServersBiz()
|
||||
{
|
||||
if (ViewModel != null)
|
||||
{
|
||||
await ViewModel.RefreshServersBiz();
|
||||
}
|
||||
|
||||
if (lstProfiles.SelectedIndex > 0)
|
||||
{
|
||||
lstProfiles.ScrollIntoView(lstProfiles.SelectedItem, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void lstProfiles_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||
{
|
||||
ViewModel.SelectedProfiles = lstProfiles.SelectedItems.Cast<ProfileItemModel>().ToList();
|
||||
|
|
Loading…
Reference in a new issue