Files
v2rayN/v2rayN/v2rayN/Common/UI.cs
T
2025-01-30 17:10:05 +08:00

60 lines
1.5 KiB
C#

using System.Windows;
using Microsoft.Win32;
namespace v2rayN
{
internal class UI
{
private static readonly string caption = Global.AppName;
public static void Show(string msg)
{
MessageBox.Show(msg, caption, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
}
public static MessageBoxResult ShowYesNo(string msg)
{
return MessageBox.Show(msg, caption, MessageBoxButton.YesNo, MessageBoxImage.Question);
}
public static bool? OpenFileDialog(out string fileName, string filter)
{
fileName = string.Empty;
var fileDialog = new OpenFileDialog
{
Multiselect = false,
Filter = filter
};
if (fileDialog.ShowDialog() != true)
{
return false;
}
fileName = fileDialog.FileName;
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;
}
}
}