using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Ursa.Controls;
using 常用工具集.Base;
using 常用工具集.ViewModels;

namespace 常用工具集.Views;

public partial class MainView : UserControl
{
    public MainView()
    {
        InitializeComponent();
    }

    protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
    {
        base.OnAttachedToVisualTree(e);
        var topLevel = TopLevel.GetTopLevel(this);
        if (topLevel is null)
            return;
        GlobalValues.StorageProvider = topLevel?.StorageProvider;
        GlobalValues.Clipboard = topLevel.Clipboard;
        GlobalValues.NotificationManager = WindowNotificationManager.TryGetNotificationManager(topLevel, out var manager) ? manager : new WindowNotificationManager(topLevel);
        GlobalValues.NotificationManager.Position = Avalonia.Controls.Notifications.NotificationPosition.BottomRight;
        GlobalValues.NotificationManager.MaxItems = 5;
    }
}