From f76b1a5363b85d422991e3af3f260c4bfcc85b99 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Wed, 31 Jan 2024 10:16:21 +0800 Subject: [PATCH] Add editing subscription in the main interface --- .../v2rayN/ViewModels/MainWindowViewModel.cs | 23 ++++++++++++++++--- v2rayN/v2rayN/Views/MainWindow.xaml | 12 +++++++++- v2rayN/v2rayN/Views/MainWindow.xaml.cs | 1 + 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs index a0935c36..299fc9e3 100644 --- a/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs @@ -128,6 +128,7 @@ namespace v2rayN.ViewModels public ReactiveCommand SubSettingCmd { get; } public ReactiveCommand AddSubCmd { get; } + public ReactiveCommand EditSubCmd { get; } public ReactiveCommand SubUpdateCmd { get; } public ReactiveCommand SubUpdateViaProxyCmd { get; } public ReactiveCommand SubGroupUpdateCmd { get; } @@ -453,7 +454,11 @@ namespace v2rayN.ViewModels }); AddSubCmd = ReactiveCommand.Create(() => { - AddSub(); + EditSub(true); + }); + EditSubCmd = ReactiveCommand.Create(() => + { + EditSub(false); }); SubUpdateCmd = ReactiveCommand.Create(() => { @@ -1329,9 +1334,21 @@ namespace v2rayN.ViewModels } } - private void AddSub() + private void EditSub(bool blNew) { - SubItem item = new(); + SubItem item; + if (blNew) + { + item = new(); + } + else + { + item = LazyConfig.Instance.GetSubItem(_subId); + if (item is null) + { + return; + } + } var ret = (new SubEditWindow(item)).ShowDialog(); if (ret == true) { diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml b/v2rayN/v2rayN/Views/MainWindow.xaml index 71e3eb72..faf41410 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml +++ b/v2rayN/v2rayN/Views/MainWindow.xaml @@ -407,6 +407,15 @@ + + + diff --git a/v2rayN/v2rayN/Views/MainWindow.xaml.cs b/v2rayN/v2rayN/Views/MainWindow.xaml.cs index e5745e8b..a5617b09 100644 --- a/v2rayN/v2rayN/Views/MainWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/MainWindow.xaml.cs @@ -79,6 +79,7 @@ namespace v2rayN.Views this.Bind(ViewModel, vm => vm.SelectedSub, v => v.lstGroup.SelectedItem).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.ServerFilter, v => v.txtServerFilter.Text).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.AddSubCmd, v => v.btnAddSub).DisposeWith(disposables); + this.BindCommand(ViewModel, vm => vm.EditSubCmd, v => v.btnEditSub).DisposeWith(disposables); //servers this.BindCommand(ViewModel, vm => vm.AddVmessServerCmd, v => v.menuAddVmessServer).DisposeWith(disposables);