Optimize custom configuration

pull/3165/head
2dust 2023-01-30 13:16:48 +08:00
parent c0c0961b2b
commit 917dc1803c
3 changed files with 15 additions and 2 deletions

View File

@ -26,6 +26,7 @@ namespace v2rayN.ViewModels
public ReactiveCommand<Unit, Unit> BrowseServerCmd { get; }
public ReactiveCommand<Unit, Unit> EditServerCmd { get; }
public ReactiveCommand<Unit, Unit> SaveServerCmd { get; }
public bool IsModified { get; set; }
public AddServer2ViewModel(ProfileItem profileItem, Window view)
{
@ -128,7 +129,11 @@ namespace v2rayN.ViewModels
if (ConfigHandler.AddCustomServer(ref _config, item, false) == 0)
{
_noticeHandler?.Enqueue(ResUI.SuccessfullyImportedCustomServer);
_view.DialogResult = true;
if (!Utils.IsNullOrEmpty(item.indexId))
{
SelectedSource = Utils.DeepCopy(item);
}
IsModified = true;
}
else
{

View File

@ -800,6 +800,7 @@ namespace v2rayN.ViewModels
{
subid = _subId,
configType = eConfigType,
displayLog = false
};
}
else

View File

@ -43,9 +43,16 @@ namespace v2rayN.Views
txtRemarks.Focus();
}
private void btnCancel_Click(object sender, System.Windows.RoutedEventArgs e)
{
if (ViewModel?.IsModified == true)
{
this.DialogResult = true;
}
else
{
this.Close();
}
}
}
}