Add editing subscription in the main interface

This commit is contained in:
2dust 2024-01-31 10:16:21 +08:00
parent 9b579be2be
commit f76b1a5363
3 changed files with 32 additions and 4 deletions

View file

@ -128,6 +128,7 @@ namespace v2rayN.ViewModels
public ReactiveCommand<Unit, Unit> SubSettingCmd { get; } public ReactiveCommand<Unit, Unit> SubSettingCmd { get; }
public ReactiveCommand<Unit, Unit> AddSubCmd { get; } public ReactiveCommand<Unit, Unit> AddSubCmd { get; }
public ReactiveCommand<Unit, Unit> EditSubCmd { get; }
public ReactiveCommand<Unit, Unit> SubUpdateCmd { get; } public ReactiveCommand<Unit, Unit> SubUpdateCmd { get; }
public ReactiveCommand<Unit, Unit> SubUpdateViaProxyCmd { get; } public ReactiveCommand<Unit, Unit> SubUpdateViaProxyCmd { get; }
public ReactiveCommand<Unit, Unit> SubGroupUpdateCmd { get; } public ReactiveCommand<Unit, Unit> SubGroupUpdateCmd { get; }
@ -453,7 +454,11 @@ namespace v2rayN.ViewModels
}); });
AddSubCmd = ReactiveCommand.Create(() => AddSubCmd = ReactiveCommand.Create(() =>
{ {
AddSub(); EditSub(true);
});
EditSubCmd = ReactiveCommand.Create(() =>
{
EditSub(false);
}); });
SubUpdateCmd = ReactiveCommand.Create(() => 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(); var ret = (new SubEditWindow(item)).ShowDialog();
if (ret == true) if (ret == true)
{ {

View file

@ -407,6 +407,15 @@
</DataTemplate> </DataTemplate>
</ListBox.ItemTemplate> </ListBox.ItemTemplate>
</ListBox> </ListBox>
<Button
x:Name="btnEditSub"
Width="30"
Height="30"
Margin="4,0"
Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}">
<materialDesign:PackIcon VerticalAlignment="Center" Kind="Edit" />
</Button>
<Button <Button
x:Name="btnAddSub" x:Name="btnAddSub"
Width="30" Width="30"
@ -415,11 +424,12 @@
Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}"> Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}">
<materialDesign:PackIcon VerticalAlignment="Center" Kind="Plus" /> <materialDesign:PackIcon VerticalAlignment="Center" Kind="Plus" />
</Button> </Button>
<Button <Button
x:Name="btnAutofitColumnWidth" x:Name="btnAutofitColumnWidth"
Width="30" Width="30"
Height="30" Height="30"
Margin="4,0" Margin="20,0"
Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}"> Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}">
<materialDesign:PackIcon VerticalAlignment="Center" Kind="ArrowSplitVertical" /> <materialDesign:PackIcon VerticalAlignment="Center" Kind="ArrowSplitVertical" />
</Button> </Button>

View file

@ -79,6 +79,7 @@ namespace v2rayN.Views
this.Bind(ViewModel, vm => vm.SelectedSub, v => v.lstGroup.SelectedItem).DisposeWith(disposables); 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.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.AddSubCmd, v => v.btnAddSub).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.EditSubCmd, v => v.btnEditSub).DisposeWith(disposables);
//servers //servers
this.BindCommand(ViewModel, vm => vm.AddVmessServerCmd, v => v.menuAddVmessServer).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.AddVmessServerCmd, v => v.menuAddVmessServer).DisposeWith(disposables);