Browse Source

Add SaveFileDialog

pull/5701/head
2dust 3 months ago
parent
commit
d03a86292e
  1. 20
      v2rayN/v2rayN/Common/UI.cs
  2. 10
      v2rayN/v2rayN/Views/ProfilesView.xaml.cs

20
v2rayN/v2rayN/Common/UI.cs

@ -35,5 +35,25 @@ namespace v2rayN
return true;
}
public static bool? SaveFileDialog(out string fileName, string filter)
{
fileName = string.Empty;
SaveFileDialog fileDialog = new()
{
Filter = filter,
FilterIndex = 2,
RestoreDirectory = true
};
if (fileDialog.ShowDialog() != true)
{
return false;
}
fileName = fileDialog.FileName;
return true;
}
}
}

10
v2rayN/v2rayN/Views/ProfilesView.xaml.cs

@ -129,17 +129,11 @@ namespace v2rayN.Views
case EViewAction.SaveFileDialog:
if (obj is null) return false;
SaveFileDialog fileDialog = new()
{
Filter = "Config|*.json",
FilterIndex = 2,
RestoreDirectory = true
};
if (fileDialog.ShowDialog() != true)
if (UI.SaveFileDialog(out string fileName, "Config|*.json") != true)
{
return false;
}
ViewModel?.Export2ClientConfigResult(fileDialog.FileName, (ProfileItem)obj);
ViewModel?.Export2ClientConfigResult(fileName, (ProfileItem)obj);
break;
case EViewAction.AddServerWindow:

Loading…
Cancel
Save