Subscription multi-select delete

pull/3611/head
2dust 2023-04-04 10:20:19 +08:00
parent 790209efbc
commit 12f3400894
2 changed files with 12 additions and 3 deletions

View File

@ -6,7 +6,6 @@ using ReactiveUI.Fody.Helpers;
using Splat; using Splat;
using System.Reactive; using System.Reactive;
using System.Windows; using System.Windows;
using System.Windows.Forms;
using v2rayN.Base; using v2rayN.Base;
using v2rayN.Handler; using v2rayN.Handler;
using v2rayN.Mode; using v2rayN.Mode;
@ -24,6 +23,7 @@ namespace v2rayN.ViewModels
public IObservableCollection<SubItem> SubItems => _subItems; public IObservableCollection<SubItem> SubItems => _subItems;
[Reactive] [Reactive]
public SubItem SelectedSource { get; set; } public SubItem SelectedSource { get; set; }
public IList<SubItem> SelectedSources { get; set; }
public ReactiveCommand<Unit, Unit> SubAddCmd { get; } public ReactiveCommand<Unit, Unit> SubAddCmd { get; }
public ReactiveCommand<Unit, Unit> SubDeleteCmd { get; } public ReactiveCommand<Unit, Unit> SubDeleteCmd { get; }
@ -96,12 +96,15 @@ namespace v2rayN.ViewModels
private void DeleteSub() private void DeleteSub()
{ {
if (UI.ShowYesNo(ResUI.RemoveServer) == DialogResult.No) if (UI.ShowYesNo(ResUI.RemoveServer) == MessageBoxResult.No)
{ {
return; return;
} }
ConfigHandler.DeleteSubItem(ref _config, SelectedSource?.id); foreach (var it in SelectedSources)
{
ConfigHandler.DeleteSubItem(ref _config, it?.id);
}
RefreshSubItems(); RefreshSubItems();
_noticeHandler?.Enqueue(ResUI.OperationSuccess); _noticeHandler?.Enqueue(ResUI.OperationSuccess);
IsModified = true; IsModified = true;

View File

@ -3,6 +3,7 @@ using System.ComponentModel;
using System.Reactive.Disposables; using System.Reactive.Disposables;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using v2rayN.Mode;
using v2rayN.ViewModels; using v2rayN.ViewModels;
namespace v2rayN.Views namespace v2rayN.Views
@ -17,6 +18,7 @@ namespace v2rayN.Views
ViewModel = new SubSettingViewModel(this); ViewModel = new SubSettingViewModel(this);
this.Closing += SubSettingWindow_Closing; this.Closing += SubSettingWindow_Closing;
lstSubscription.MouseDoubleClick += LstSubscription_MouseDoubleClick; lstSubscription.MouseDoubleClick += LstSubscription_MouseDoubleClick;
lstSubscription.SelectionChanged += LstSubscription_SelectionChanged;
this.WhenActivated(disposables => this.WhenActivated(disposables =>
{ {
@ -43,6 +45,10 @@ namespace v2rayN.Views
{ {
ViewModel?.EditSub(false); ViewModel?.EditSub(false);
} }
private void LstSubscription_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
{
ViewModel.SelectedSources = lstSubscription.SelectedItems.Cast<SubItem>().ToList();
}
private void menuClose_Click(object sender, System.Windows.RoutedEventArgs e) private void menuClose_Click(object sender, System.Windows.RoutedEventArgs e)
{ {