using System; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.InteropServices; using Avalonia.Interactivity; using Avalonia.ReactiveUI; using AvaloniaApplication1.ViewModels; using MsBox.Avalonia; using MsBox.Avalonia.Dto; using MsBox.Avalonia.Models; namespace AvaloniaApplication1.Views; public partial class MainWindow : ReactiveWindow { public MainWindow() { InitializeComponent(); } private async void MainButtOnClick(object? sender, RoutedEventArgs e) { var showAsync = MessageBoxManager.GetMessageBoxCustom(new MessageBoxCustomParams { ButtonDefinitions = new List { new() { Name = "是" }, new() { Name = "否" }, new() { Name = "Cancel" } }, ContentTitle = "title", ContentMessage = "Informative note:" + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc ut pulvinar est, eget porttitor magna. Maecenas nunc elit, pretium nec mauris vel, cursus faucibus leo. Mauris consequat magna vel mi malesuada semper. Donec nunc justo, rhoncus vel viverra a, ultrices vel nibh. Praesent ut libero a nunc placerat vulputate. Morbi ullamcorper pharetra lectus, ut lobortis ex consequat sit amet. Vestibulum pellentesque quam at justo hendrerit, et tincidunt nisl mattis. Curabitur eu nibh enim.\n", Icon = MsBox.Avalonia.Enums.Icon.Question, CanResize = false, MaxWidth = 500, MaxHeight = 800, ShowInCenter = true, Topmost = false, HyperLinkParams = new HyperLinkParams { Text = "https://docs.avaloniaui.net/", Action = () => { var desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); var url = "https://docs.avaloniaui.net/"; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { //https://stackoverflow.com/a/2796367/241446 using var proc = new Process(); proc.StartInfo.UseShellExecute = true; proc.StartInfo.FileName = url; proc.Start(); return; } if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { Process.Start("x-www-browser", url); return; } if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) throw new Exception("invalid url: " + url); Process.Start("open", url); } } }).ShowAsync(); Console.WriteLine(await showAsync); } private void ShowLayoutOnClick(object? sender, RoutedEventArgs e) { var layoutWindow = new LayoutWindow(); layoutWindow.ShowDialog(this); } private void ShowDemo1OnClick(object? sender, RoutedEventArgs e) { var layoutDemo1 = new LayoutDemo1(); layoutDemo1.ShowDialog(this); } }