* Multi Profile * VM and wpf * avalonia * Fix right click not working * Exclude specific profile types from selection * Rename * Add Policy Group support * Add generate policy group * Adjust UI * Add Proxy Chain support * Fix * Add fallback support * Add PolicyGroup include other Group support * Add group in traffic splitting support * Avoid duplicate tags * Refactor * Adjust chained proxy, actual outbound is at the top Based on actual network flow instead of data packets * Add helper function * Refactor * Add chain selection control to group outbounds * Avoid self-reference * Fix * Improves Tun2Socks address handling * Avoids circular dependency in profile groups Adds cycle detection to prevent infinite loops when evaluating profile groups. This ensures that profile group configurations don't result in stack overflow errors when groups reference each other, directly or indirectly. * Fix * Fix * Update ProfileGroupItem.cs * Refactor * Remove unnecessary checks --------- Co-authored-by: 2dust <31833384+2dust@users.noreply.github.com>
93 lines
3.8 KiB
C#
93 lines
3.8 KiB
C#
using System.Reactive.Disposables;
|
|
using Avalonia;
|
|
using Avalonia.Interactivity;
|
|
using ReactiveUI;
|
|
using v2rayN.Desktop.Base;
|
|
|
|
namespace v2rayN.Desktop.Views;
|
|
|
|
public partial class SubEditWindow : WindowBase<SubEditViewModel>
|
|
{
|
|
public SubEditWindow()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public SubEditWindow(SubItem subItem)
|
|
{
|
|
InitializeComponent();
|
|
|
|
Loaded += Window_Loaded;
|
|
btnCancel.Click += (s, e) => this.Close();
|
|
|
|
ViewModel = new SubEditViewModel(subItem, UpdateViewHandler);
|
|
|
|
cmbConvertTarget.ItemsSource = Global.SubConvertTargets;
|
|
|
|
this.WhenActivated(disposables =>
|
|
{
|
|
this.Bind(ViewModel, vm => vm.SelectedSource.Remarks, v => v.txtRemarks.Text).DisposeWith(disposables);
|
|
this.Bind(ViewModel, vm => vm.SelectedSource.Url, v => v.txtUrl.Text).DisposeWith(disposables);
|
|
this.Bind(ViewModel, vm => vm.SelectedSource.MoreUrl, v => v.txtMoreUrl.Text).DisposeWith(disposables);
|
|
this.Bind(ViewModel, vm => vm.SelectedSource.Enabled, v => v.togEnable.IsChecked).DisposeWith(disposables);
|
|
this.Bind(ViewModel, vm => vm.SelectedSource.AutoUpdateInterval, v => v.txtAutoUpdateInterval.Text).DisposeWith(disposables);
|
|
this.Bind(ViewModel, vm => vm.SelectedSource.UserAgent, v => v.txtUserAgent.Text).DisposeWith(disposables);
|
|
this.Bind(ViewModel, vm => vm.SelectedSource.Sort, v => v.txtSort.Text).DisposeWith(disposables);
|
|
this.Bind(ViewModel, vm => vm.SelectedSource.Filter, v => v.txtFilter.Text).DisposeWith(disposables);
|
|
this.Bind(ViewModel, vm => vm.SelectedSource.ConvertTarget, v => v.cmbConvertTarget.SelectedValue).DisposeWith(disposables);
|
|
this.Bind(ViewModel, vm => vm.SelectedSource.PrevProfile, v => v.txtPrevProfile.Text).DisposeWith(disposables);
|
|
this.Bind(ViewModel, vm => vm.SelectedSource.NextProfile, v => v.txtNextProfile.Text).DisposeWith(disposables);
|
|
this.Bind(ViewModel, vm => vm.SelectedSource.PreSocksPort, v => v.txtPreSocksPort.Text).DisposeWith(disposables);
|
|
this.Bind(ViewModel, vm => vm.SelectedSource.Memo, v => v.txtMemo.Text).DisposeWith(disposables);
|
|
|
|
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
|
});
|
|
}
|
|
|
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
|
{
|
|
switch (action)
|
|
{
|
|
case EViewAction.CloseWindow:
|
|
this.Close(true);
|
|
break;
|
|
}
|
|
return await Task.FromResult(true);
|
|
}
|
|
|
|
private void Window_Loaded(object? sender, RoutedEventArgs e)
|
|
{
|
|
txtRemarks.Focus();
|
|
}
|
|
|
|
private async void BtnSelectPrevProfile_Click(object? sender, RoutedEventArgs e)
|
|
{
|
|
var selectWindow = new ProfilesSelectWindow();
|
|
selectWindow.SetConfigTypeFilter(new[] { EConfigType.Custom, EConfigType.PolicyGroup, EConfigType.ProxyChain }, exclude: true);
|
|
var result = await selectWindow.ShowDialog<bool?>(this);
|
|
if (result == true)
|
|
{
|
|
var profile = await selectWindow.ProfileItem;
|
|
if (profile != null)
|
|
{
|
|
txtPrevProfile.Text = profile.Remarks;
|
|
}
|
|
}
|
|
}
|
|
|
|
private async void BtnSelectNextProfile_Click(object? sender, RoutedEventArgs e)
|
|
{
|
|
var selectWindow = new ProfilesSelectWindow();
|
|
selectWindow.SetConfigTypeFilter(new[] { EConfigType.Custom, EConfigType.PolicyGroup, EConfigType.ProxyChain }, exclude: true);
|
|
var result = await selectWindow.ShowDialog<bool?>(this);
|
|
if (result == true)
|
|
{
|
|
var profile = await selectWindow.ProfileItem;
|
|
if (profile != null)
|
|
{
|
|
txtNextProfile.Text = profile.Remarks;
|
|
}
|
|
}
|
|
}
|
|
}
|