mirror of
https://github.com/2dust/v2rayN.git
synced 2026-04-19 22:15:46 +00:00
Custom MessageBoxDialog (#9147)
This commit is contained in:
parent
b604a5b787
commit
171ed6f58f
7 changed files with 94 additions and 6 deletions
|
|
@ -9,13 +9,13 @@
|
|||
<PackageVersion Include="Avalonia.Controls.DataGrid" Version="11.3.13" />
|
||||
<PackageVersion Include="Avalonia.Desktop" Version="11.3.13" />
|
||||
<PackageVersion Include="Avalonia.Diagnostics" Version="11.3.13" />
|
||||
<PackageVersion Include="DialogHost.Avalonia" Version="0.11.0" />
|
||||
<PackageVersion Include="ReactiveUI.Avalonia" Version="11.4.12" />
|
||||
<PackageVersion Include="CliWrap" Version="3.10.1" />
|
||||
<PackageVersion Include="Downloader" Version="5.1.0" />
|
||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
||||
<PackageVersion Include="H.NotifyIcon.Wpf" Version="2.4.1" />
|
||||
<PackageVersion Include="MaterialDesignThemes" Version="5.3.1" />
|
||||
<PackageVersion Include="MessageBox.Avalonia" Version="3.3.1.1" />
|
||||
<PackageVersion Include="QRCoder" Version="1.8.0" />
|
||||
<PackageVersion Include="ReactiveUI" Version="23.2.1" />
|
||||
<PackageVersion Include="ReactiveUI.Fody" Version="19.5.41" />
|
||||
|
|
|
|||
8
v2rayN/v2rayN.Desktop/Common/ButtonResult.cs
Normal file
8
v2rayN/v2rayN.Desktop/Common/ButtonResult.cs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
namespace v2rayN.Desktop.Common;
|
||||
|
||||
public enum ButtonResult
|
||||
{
|
||||
None = 0,
|
||||
Yes = 1,
|
||||
No = 2
|
||||
}
|
||||
|
|
@ -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<ButtonResult> 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<ButtonResult>(owner);
|
||||
return result == ButtonResult.Yes ? ButtonResult.Yes : ButtonResult.No;
|
||||
}
|
||||
|
||||
public static async Task<string?> OpenFileDialog(Window owner, FilePickerFileType? filter)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
53
v2rayN/v2rayN.Desktop/Views/MessageBoxDialog.axaml
Normal file
53
v2rayN/v2rayN.Desktop/Views/MessageBoxDialog.axaml
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<Window
|
||||
x:Class="v2rayN.Desktop.Views.MessageBoxDialog"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:resx="clr-namespace:ServiceLib.Resx;assembly=ServiceLib"
|
||||
Width="420"
|
||||
MinWidth="350"
|
||||
MaxWidth="600"
|
||||
CanResize="False"
|
||||
ShowInTaskbar="False"
|
||||
SizeToContent="Height"
|
||||
SystemDecorations="Full"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid Margin="24" RowDefinitions="*,Auto">
|
||||
<ScrollViewer
|
||||
Grid.Row="0"
|
||||
MinHeight="60"
|
||||
MaxHeight="300"
|
||||
Margin="0,0,0,24"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="Auto">
|
||||
<TextBlock
|
||||
x:Name="txtMessage"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="14"
|
||||
LineHeight="22"
|
||||
TextWrapping="Wrap" />
|
||||
</ScrollViewer>
|
||||
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal"
|
||||
Spacing="12">
|
||||
<Button
|
||||
x:Name="btnYes"
|
||||
MinWidth="90"
|
||||
HorizontalContentAlignment="Center"
|
||||
Content="{x:Static resx:ResUI.TbConfirm}"
|
||||
IsDefault="True" />
|
||||
<Button
|
||||
x:Name="btnNo"
|
||||
MinWidth="90"
|
||||
HorizontalContentAlignment="Center"
|
||||
Content="{x:Static resx:ResUI.TbCancel}"
|
||||
IsCancel="True" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
27
v2rayN/v2rayN.Desktop/Views/MessageBoxDialog.axaml.cs
Normal file
27
v2rayN/v2rayN.Desktop/Views/MessageBoxDialog.axaml.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using v2rayN.Desktop.Common;
|
||||
|
||||
namespace v2rayN.Desktop.Views;
|
||||
|
||||
public partial class MessageBoxDialog : Window
|
||||
{
|
||||
public MessageBoxDialog(string caption, string message)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Title = caption;
|
||||
txtMessage.Text = message;
|
||||
|
||||
btnYes.Click += BtnYes_Click;
|
||||
btnNo.Click += BtnNo_Click;
|
||||
}
|
||||
|
||||
private void BtnYes_Click(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
Close(ButtonResult.Yes);
|
||||
}
|
||||
|
||||
private void BtnNo_Click(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
Close(ButtonResult.No);
|
||||
}
|
||||
}
|
||||
|
|
@ -16,8 +16,8 @@
|
|||
</PackageReference>
|
||||
<PackageReference Include="Avalonia.Desktop" />
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" />
|
||||
<PackageReference Include="DialogHost.Avalonia" />
|
||||
<PackageReference Include="ReactiveUI.Avalonia" />
|
||||
<PackageReference Include="MessageBox.Avalonia" />
|
||||
<PackageReference Include="Semi.Avalonia" />
|
||||
<PackageReference Include="Semi.Avalonia.AvaloniaEdit" />
|
||||
<PackageReference Include="Semi.Avalonia.DataGrid">
|
||||
|
|
|
|||
Loading…
Reference in a new issue