mirror of
https://github.com/2dust/v2rayN.git
synced 2026-09-28 09:48:02 +03:00
* Interaction * Remove view action * ViewModel-first * MainGirdOrientation Hot Reload * Fix avalonia preview * Remove CloseWindowInteraction * Fix * Avoid threading issues * Fix * ProfilesSelect * Try fix previewer * Remove AppEvents.ProfilesRefreshRequested * Remove AppEvents.SubscriptionsRefreshRequested * Remove AppEvents.ProxiesReloadRequested * Remove AppEvents.AdjustMainLvColWidthRequested * Remove AppEvents.SetDefaultServerRequested * Remove AppEvents.RoutingsMenuRefreshRequested * Remove AppEvents.TestServerRequested * Remove AppEvents.InboundDisplayRequested * Remove AppEvents.SubscriptionsUpdateRequested * Remove AppEvents.ShowHideWindowRequested * Remove AppEvents.ReloadRequested * Remove AppEvents.AddServerRequested * Fix
60 lines
1.7 KiB
C#
60 lines
1.7 KiB
C#
using Avalonia.Platform.Storage;
|
|
using v2rayN.Desktop.Manager;
|
|
using v2rayN.Desktop.Views;
|
|
|
|
namespace v2rayN.Desktop.Common;
|
|
|
|
internal class UI
|
|
{
|
|
private static readonly string caption = Global.AppName;
|
|
|
|
public static async Task<ButtonResult> ShowYesNo(string msg)
|
|
{
|
|
var owner = WindowDialog.TryGetOwnerWindow();
|
|
var box = new MessageBoxDialog(caption, msg);
|
|
var result = await box.ShowDialog<ButtonResult>(owner);
|
|
return result == ButtonResult.Yes ? ButtonResult.Yes : ButtonResult.No;
|
|
}
|
|
|
|
public static async Task<string?> OpenFileDialog(FilePickerFileType? filter)
|
|
{
|
|
var sp = GetStorageProvider();
|
|
if (sp is null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
// 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();
|
|
}
|
|
|
|
public static async Task<string?> SaveFileDialog(string filter)
|
|
{
|
|
var sp = GetStorageProvider();
|
|
if (sp is null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
// Start async operation to open the dialog.
|
|
var files = await sp.SaveFilePickerAsync(new FilePickerSaveOptions
|
|
{
|
|
});
|
|
|
|
return files?.TryGetLocalPath();
|
|
}
|
|
|
|
private static IStorageProvider? GetStorageProvider()
|
|
{
|
|
var owner = WindowDialog.TryGetOwnerWindow();
|
|
var topLevel = TopLevel.GetTopLevel(owner);
|
|
return topLevel?.StorageProvider;
|
|
}
|
|
}
|