mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-15 08:55:00 +03:00
csharp_style_namespace_declarations = file_scoped
This commit is contained in:
@@ -3,56 +3,55 @@ using Avalonia.Platform.Storage;
|
||||
using MsBox.Avalonia;
|
||||
using MsBox.Avalonia.Enums;
|
||||
|
||||
namespace v2rayN.Desktop.Common
|
||||
namespace v2rayN.Desktop.Common;
|
||||
|
||||
internal class UI
|
||||
{
|
||||
internal class UI
|
||||
private static readonly string caption = Global.AppName;
|
||||
|
||||
public static async Task<ButtonResult> ShowYesNo(Window owner, string msg)
|
||||
{
|
||||
private static readonly string caption = Global.AppName;
|
||||
var box = MessageBoxManager.GetMessageBoxStandard(caption, msg, ButtonEnum.YesNo);
|
||||
return await box.ShowWindowDialogAsync(owner);
|
||||
}
|
||||
|
||||
public static async Task<ButtonResult> ShowYesNo(Window owner, string msg)
|
||||
public static async Task<string?> OpenFileDialog(Window owner, FilePickerFileType? filter)
|
||||
{
|
||||
var sp = GetStorageProvider(owner);
|
||||
if (sp is null)
|
||||
{
|
||||
var box = MessageBoxManager.GetMessageBoxStandard(caption, msg, ButtonEnum.YesNo);
|
||||
return await box.ShowWindowDialogAsync(owner);
|
||||
return null;
|
||||
}
|
||||
|
||||
public static async Task<string?> OpenFileDialog(Window owner, FilePickerFileType? filter)
|
||||
// Start async operation to open the dialog.
|
||||
var files = await sp.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
var sp = GetStorageProvider(owner);
|
||||
if (sp is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
AllowMultiple = false,
|
||||
FileTypeFilter = filter is null ? [FilePickerFileTypes.All, FilePickerFileTypes.ImagePng] : [filter]
|
||||
});
|
||||
|
||||
// Start async operation to open the dialog.
|
||||
var files = await sp.OpenFilePickerAsync(new FilePickerOpenOptions
|
||||
{
|
||||
AllowMultiple = false,
|
||||
FileTypeFilter = filter is null ? [FilePickerFileTypes.All, FilePickerFileTypes.ImagePng] : [filter]
|
||||
});
|
||||
return files.FirstOrDefault()?.TryGetLocalPath();
|
||||
}
|
||||
|
||||
return files.FirstOrDefault()?.TryGetLocalPath();
|
||||
public static async Task<string?> SaveFileDialog(Window owner, string filter)
|
||||
{
|
||||
var sp = GetStorageProvider(owner);
|
||||
if (sp is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public static async Task<string?> SaveFileDialog(Window owner, string filter)
|
||||
// Start async operation to open the dialog.
|
||||
var files = await sp.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
var sp = GetStorageProvider(owner);
|
||||
if (sp is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
// Start async operation to open the dialog.
|
||||
var files = await sp.SaveFilePickerAsync(new FilePickerSaveOptions
|
||||
{
|
||||
});
|
||||
return files?.TryGetLocalPath();
|
||||
}
|
||||
|
||||
return files?.TryGetLocalPath();
|
||||
}
|
||||
|
||||
private static IStorageProvider? GetStorageProvider(Window owner)
|
||||
{
|
||||
var topLevel = TopLevel.GetTopLevel(owner);
|
||||
return topLevel?.StorageProvider;
|
||||
}
|
||||
private static IStorageProvider? GetStorageProvider(Window owner)
|
||||
{
|
||||
var topLevel = TopLevel.GetTopLevel(owner);
|
||||
return topLevel?.StorageProvider;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user