|
|
@@ -1,53 +0,0 @@
|
|
|
-using System;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Linq;
|
|
|
-using Avalonia.Threading;
|
|
|
-
|
|
|
-namespace Avalonia.Controls.Notifications
|
|
|
-{
|
|
|
- public class NotificationManager : INotificationManager
|
|
|
- {
|
|
|
- private static readonly List<NotificationArea> Areas = new List<NotificationArea>();
|
|
|
- private static Window _window;
|
|
|
-
|
|
|
- public static NotificationManager Instance = new NotificationManager();
|
|
|
-
|
|
|
- public void Show(object content, string areaName = "", TimeSpan? expirationTime = null, Action onClick = null,
|
|
|
- Action onClose = null)
|
|
|
- {
|
|
|
- if (!Dispatcher.UIThread.CheckAccess())
|
|
|
- {
|
|
|
- Dispatcher.UIThread.Post(
|
|
|
- new Action(() => Show(content, areaName, expirationTime, onClick, onClose)));
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (expirationTime == null)
|
|
|
- expirationTime = TimeSpan.FromSeconds(5);
|
|
|
-
|
|
|
- if (areaName == string.Empty && _window == null)
|
|
|
- {
|
|
|
- var workArea = Application.Current.MainWindow.Screens.Primary.WorkingArea;
|
|
|
-
|
|
|
- _window = new Window
|
|
|
- {
|
|
|
- Position = workArea.Position,
|
|
|
- Width = workArea.Width,
|
|
|
- Height = workArea.Height
|
|
|
- };
|
|
|
-
|
|
|
- _window.Show();
|
|
|
- }
|
|
|
-
|
|
|
- foreach (var area in Areas.Where(a => a.Name == areaName))
|
|
|
- {
|
|
|
- area.Show(content, (TimeSpan)expirationTime, onClick, onClose);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- internal static void AddArea(NotificationArea area)
|
|
|
- {
|
|
|
- Areas.Add(area);
|
|
|
- }
|
|
|
- }
|
|
|
-}
|