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; 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: case EViewAction.SaveFileDialog:
if (obj is null) return false; if (obj is null) return false;
SaveFileDialog fileDialog = new() if (UI.SaveFileDialog(out string fileName, "Config|*.json") != true)
{
Filter = "Config|*.json",
FilterIndex = 2,
RestoreDirectory = true
};
if (fileDialog.ShowDialog() != true)
{ {
return false; return false;
} }
ViewModel?.Export2ClientConfigResult(fileDialog.FileName, (ProfileItem)obj); ViewModel?.Export2ClientConfigResult(fileName, (ProfileItem)obj);
break; break;
case EViewAction.AddServerWindow: case EViewAction.AddServerWindow:

Loading…
Cancel
Save