From 171ed6f58f057e326ec78b3dd20db92dd34b7d41 Mon Sep 17 00:00:00 2001 From: DHR60 Date: Sun, 19 Apr 2026 09:06:15 +0000 Subject: [PATCH] Custom MessageBoxDialog (#9147) --- v2rayN/Directory.Packages.props | 2 +- v2rayN/v2rayN.Desktop/Common/ButtonResult.cs | 8 +++ v2rayN/v2rayN.Desktop/Common/UI.cs | 7 +-- v2rayN/v2rayN.Desktop/GlobalUsings.cs | 1 - .../Views/MessageBoxDialog.axaml | 53 +++++++++++++++++++ .../Views/MessageBoxDialog.axaml.cs | 27 ++++++++++ v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj | 2 +- 7 files changed, 94 insertions(+), 6 deletions(-) create mode 100644 v2rayN/v2rayN.Desktop/Common/ButtonResult.cs create mode 100644 v2rayN/v2rayN.Desktop/Views/MessageBoxDialog.axaml create mode 100644 v2rayN/v2rayN.Desktop/Views/MessageBoxDialog.axaml.cs diff --git a/v2rayN/Directory.Packages.props b/v2rayN/Directory.Packages.props index d441b382..453c4d40 100644 --- a/v2rayN/Directory.Packages.props +++ b/v2rayN/Directory.Packages.props @@ -9,13 +9,13 @@ + - diff --git a/v2rayN/v2rayN.Desktop/Common/ButtonResult.cs b/v2rayN/v2rayN.Desktop/Common/ButtonResult.cs new file mode 100644 index 00000000..6f939d8d --- /dev/null +++ b/v2rayN/v2rayN.Desktop/Common/ButtonResult.cs @@ -0,0 +1,8 @@ +namespace v2rayN.Desktop.Common; + +public enum ButtonResult +{ + None = 0, + Yes = 1, + No = 2 +} diff --git a/v2rayN/v2rayN.Desktop/Common/UI.cs b/v2rayN/v2rayN.Desktop/Common/UI.cs index c17d8947..990e3c68 100644 --- a/v2rayN/v2rayN.Desktop/Common/UI.cs +++ b/v2rayN/v2rayN.Desktop/Common/UI.cs @@ -1,5 +1,5 @@ using Avalonia.Platform.Storage; -using MsBox.Avalonia; +using v2rayN.Desktop.Views; namespace v2rayN.Desktop.Common; @@ -9,8 +9,9 @@ internal class UI public static async Task ShowYesNo(Window owner, string msg) { - var box = MessageBoxManager.GetMessageBoxStandard(caption, msg, ButtonEnum.YesNo); - return await box.ShowWindowDialogAsync(owner); + var box = new MessageBoxDialog(caption, msg); + var result = await box.ShowDialog(owner); + return result == ButtonResult.Yes ? ButtonResult.Yes : ButtonResult.No; } public static async Task OpenFileDialog(Window owner, FilePickerFileType? filter) diff --git a/v2rayN/v2rayN.Desktop/GlobalUsings.cs b/v2rayN/v2rayN.Desktop/GlobalUsings.cs index e7499b01..5b0b2158 100644 --- a/v2rayN/v2rayN.Desktop/GlobalUsings.cs +++ b/v2rayN/v2rayN.Desktop/GlobalUsings.cs @@ -20,7 +20,6 @@ global using Avalonia.Platform; global using Avalonia.Styling; global using Avalonia.Threading; global using DynamicData; -global using MsBox.Avalonia.Enums; global using ReactiveUI; global using ReactiveUI.Avalonia; global using ReactiveUI.Fody.Helpers; diff --git a/v2rayN/v2rayN.Desktop/Views/MessageBoxDialog.axaml b/v2rayN/v2rayN.Desktop/Views/MessageBoxDialog.axaml new file mode 100644 index 00000000..dae11854 --- /dev/null +++ b/v2rayN/v2rayN.Desktop/Views/MessageBoxDialog.axaml @@ -0,0 +1,53 @@ + + + + + + + + +