feat: Notification Position.
This commit is contained in:
@@ -1,6 +1,40 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Notifications;
|
||||
using Avalonia.LogicalTree;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// Control that represents and displays a notification.
|
||||
/// </summary>
|
||||
public class NotificationCard : MessageCard;
|
||||
public class NotificationCard : MessageCard
|
||||
{
|
||||
private NotificationPosition _position;
|
||||
|
||||
public NotificationPosition Position
|
||||
{
|
||||
get => _position;
|
||||
set => SetAndRaise(PositionProperty, ref _position, value);
|
||||
}
|
||||
|
||||
public static readonly DirectProperty<NotificationCard, NotificationPosition> PositionProperty =
|
||||
AvaloniaProperty.RegisterDirect<NotificationCard, NotificationPosition>(nameof(Position),
|
||||
o => o.Position, (o, v) => o.Position = v);
|
||||
|
||||
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnAttachedToLogicalTree(e);
|
||||
UpdatePseudoClasses(Position);
|
||||
}
|
||||
|
||||
private void UpdatePseudoClasses(NotificationPosition position)
|
||||
{
|
||||
PseudoClasses.Set(WindowNotificationManager.PC_TopLeft, position == NotificationPosition.TopLeft);
|
||||
PseudoClasses.Set(WindowNotificationManager.PC_TopRight, position == NotificationPosition.TopRight);
|
||||
PseudoClasses.Set(WindowNotificationManager.PC_BottomLeft, position == NotificationPosition.BottomLeft);
|
||||
PseudoClasses.Set(WindowNotificationManager.PC_BottomRight, position == NotificationPosition.BottomRight);
|
||||
PseudoClasses.Set(WindowNotificationManager.PC_TopCenter, position == NotificationPosition.TopCenter);
|
||||
PseudoClasses.Set(WindowNotificationManager.PC_BottomCenter, position == NotificationPosition.BottomCenter);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user