feat: Notification Position.
This commit is contained in:
@@ -22,8 +22,36 @@
|
||||
<ReversibleStackPanel Name="PART_Items" />
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
<Style Selector="^ /template/ ReversibleStackPanel#PART_Items">
|
||||
<Style Selector="^:topleft /template/ ReversibleStackPanel#PART_Items">
|
||||
<Setter Property="VerticalAlignment" Value="Top" />
|
||||
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:topright /template/ ReversibleStackPanel#PART_Items">
|
||||
<Setter Property="VerticalAlignment" Value="Top" />
|
||||
<Setter Property="HorizontalAlignment" Value="Right" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:topcenter /template/ ReversibleStackPanel#PART_Items">
|
||||
<Setter Property="VerticalAlignment" Value="Top" />
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:bottomleft /template/ ReversibleStackPanel#PART_Items">
|
||||
<Setter Property="ReverseOrder" Value="True" />
|
||||
<Setter Property="VerticalAlignment" Value="Bottom" />
|
||||
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:bottomright /template/ ReversibleStackPanel#PART_Items">
|
||||
<Setter Property="ReverseOrder" Value="True" />
|
||||
<Setter Property="VerticalAlignment" Value="Bottom" />
|
||||
<Setter Property="HorizontalAlignment" Value="Right" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:bottomcenter /template/ ReversibleStackPanel#PART_Items">
|
||||
<Setter Property="ReverseOrder" Value="True" />
|
||||
<Setter Property="VerticalAlignment" Value="Bottom" />
|
||||
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
@@ -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