mirror of
https://github.com/2dust/v2rayN.git
synced 2026-10-19 19:55:00 +03:00
60 lines
1.5 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|