feat: add default template.

This commit is contained in:
rabbitism
2024-01-10 22:38:50 +08:00
parent abb1bffaeb
commit 81d54d3b28
11 changed files with 117 additions and 5 deletions

View File

@@ -1,12 +1,28 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
namespace Ursa.Controls.MessageBox;
namespace Ursa.Controls;
public static class MessageBox
{
public static async Task ShowAsync(string message)
{
var messageWindow = new MessageBoxWindow();
var messageWindow = new MessageBoxWindow()
{
Content = message
};
var lifetime = Application.Current?.ApplicationLifetime;
if (lifetime is IClassicDesktopStyleApplicationLifetime classLifetime)
{
var main = classLifetime.MainWindow;
if (main is null)
{
messageWindow.Show();
}
else
{
await messageWindow.ShowDialog(main);
}
}
}
}

View File

@@ -1,7 +1,7 @@
using Avalonia.Controls;
using Avalonia.Platform;
namespace Ursa.Controls.MessageBox;
namespace Ursa.Controls;
public class MessageBoxWindow: Window
{
@@ -9,7 +9,6 @@ public class MessageBoxWindow: Window
static MessageBoxWindow()
{
ExtendClientAreaChromeHintsProperty.OverrideDefaultValue<MessageBoxWindow>(ExtendClientAreaChromeHints
.NoChrome);
}
}