From 3ac546ba98f24a47509bd0330956a1fdb12fbdce Mon Sep 17 00:00:00 2001 From: CreateLab <33497292+CreateLab@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:25:49 +0300 Subject: [PATCH] Update README.md --- README.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e784dcc..bfdaf54 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,70 @@ The easiest way to get started is this: var result = await box.ShowAsync(); ``` - -Other examples: ![wiki](https://github.com/AvaloniaCommunity/MessageBox.Avalonia/wiki/Examples) +You have a lot of options how to show your messagebox +`ShowAsync` - Show messagebox depending on the type of application + If application is SingleViewApplicationLifetime (Mobile or Browses) then show messagebox as popup + If application is ClassicDesktopStyleApplicationLifetime (Desktop) then show messagebox as window + +`ShowWindowAsync` - Show messagebox as window + +`ShowWindowDialogAsync` - Show messagebox as window with owner + +`ShowAsPopupAsync` - Show messagebox as popup + + +HyperLink with powerfull options +```cs +MessageBoxManager.GetMessageBoxCustom( + new MessageBoxCustomParams + { + ButtonDefinitions = new List + { + new ButtonDefinition { Name = "Yes", }, + new ButtonDefinition { Name = "No", }, + new ButtonDefinition { 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, + WindowStartupLocation = WindowStartupLocation.CenterOwner, + CanResize = false, + MaxWidth = 500, + MaxHeight = 800, + SizeToContent = SizeToContent.WidthAndHeight, + ShowInCenter = true, + Topmost = false, + HyperLinkParams = new HyperLinkParams + { + Text = "https://docs.avaloniaui.net/", + Action = new 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 { StartInfo = { UseShellExecute = true, 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); + return; + }) + } + }); +``` Support: https://t.me/Avalonia