detect/detect.gui/VWS/NotificationWindow.axaml.cs

84 lines
2.5 KiB
C#
Raw Normal View History

2024-11-27 15:20:42 +08:00
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Platform;
namespace detect.gui.VWS;
public partial class NotificationWindow : Window
{
private static NotificationWindow? _instance;
public static NotificationWindow Instance()
{
return _instance ??= new NotificationWindow();
}
public static readonly StyledProperty<bool> IsSuccessProperty =
AvaloniaProperty.Register<NotificationWindow, bool>(nameof(IsSuccess));
public bool IsSuccess
{
get => GetValue(IsSuccessProperty);
set => SetValue(IsSuccessProperty, value);
}
public static readonly StyledProperty<bool> IsErrorProperty =
AvaloniaProperty.Register<NotificationWindow, bool>(nameof(IsError));
public bool IsError
{
get => GetValue(IsErrorProperty);
set => SetValue(IsErrorProperty, value);
}
public static readonly StyledProperty<bool> IsInformationProperty =
AvaloniaProperty.Register<NotificationWindow, bool>(nameof(IsInformation));
public bool IsInformation
{
get => GetValue(IsInformationProperty);
set => SetValue(IsInformationProperty, value);
}
public static readonly StyledProperty<bool> IsWarningProperty =
AvaloniaProperty.Register<NotificationWindow, bool>(nameof(IsWarning));
public bool IsWarning
{
get => GetValue(IsWarningProperty);
set => SetValue(IsWarningProperty, value);
}
public static readonly StyledProperty<string?> MessageProperty =
AvaloniaProperty.Register<NotificationWindow, string?>(nameof(Message));
public string? Message
{
get => GetValue(MessageProperty);
set => SetValue(MessageProperty, value);
}
public NotificationWindow()
{
InitializeComponent();
ExtendClientAreaToDecorationsHint = true;
ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.NoChrome;
ExtendClientAreaTitleBarHeightHint = -1;
SystemDecorations = SystemDecorations.None;
Topmost = false;
ShowInTaskbar = false;
CanResize = false;
if (Screens.Primary == null) return;
var w = Screens.Primary.Bounds.Width / Screens.Primary.Scaling;
var h = Screens.Primary.Bounds.Height / Screens.Primary.Scaling;
Position = new PixelPoint((int)(w - 260), (int)(h - 93));
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}