Skip to content

Commit

Permalink
Add editing subscription in the main interface
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Jan 31, 2024
1 parent 9b579be commit f76b1a5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
23 changes: 20 additions & 3 deletions v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public class MainWindowViewModel : ReactiveObject
public ReactiveCommand<Unit, Unit> SubSettingCmd { get; }

public ReactiveCommand<Unit, Unit> AddSubCmd { get; }
public ReactiveCommand<Unit, Unit> EditSubCmd { get; }
public ReactiveCommand<Unit, Unit> SubUpdateCmd { get; }
public ReactiveCommand<Unit, Unit> SubUpdateViaProxyCmd { get; }
public ReactiveCommand<Unit, Unit> SubGroupUpdateCmd { get; }
Expand Down Expand Up @@ -453,7 +454,11 @@ public MainWindowViewModel(ISnackbarMessageQueue snackbarMessageQueue, Action<EV
});
AddSubCmd = ReactiveCommand.Create(() =>
{
AddSub();
EditSub(true);
});
EditSubCmd = ReactiveCommand.Create(() =>
{
EditSub(false);
});
SubUpdateCmd = ReactiveCommand.Create(() =>
{
Expand Down Expand Up @@ -1329,9 +1334,21 @@ private void SubSetting()
}
}

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)
{
Expand Down
12 changes: 11 additions & 1 deletion v2rayN/v2rayN/Views/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,15 @@
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

<Button
x:Name="btnEditSub"
Width="30"
Height="30"
Margin="4,0"
Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}">
<materialDesign:PackIcon VerticalAlignment="Center" Kind="Edit" />
</Button>
<Button
x:Name="btnAddSub"
Width="30"
Expand All @@ -415,11 +424,12 @@
Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}">
<materialDesign:PackIcon VerticalAlignment="Center" Kind="Plus" />
</Button>

<Button
x:Name="btnAutofitColumnWidth"
Width="30"
Height="30"
Margin="4,0"
Margin="20,0"
Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}">
<materialDesign:PackIcon VerticalAlignment="Center" Kind="ArrowSplitVertical" />
</Button>
Expand Down
1 change: 1 addition & 0 deletions v2rayN/v2rayN/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public MainWindow()
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);
Expand Down

0 comments on commit f76b1a5

Please sign in to comment.