public static async void Init(Action setterNewNotify) { setNewNotification = setterNewNotify; Load(); GetNotify(); while (true) { while (popupNotifies.Count != 0) { PopupNotify popup; lock (sync) { NotifyModel popupModel = popupNotifies.Dequeue(); popup = new PopupNotify(popupModel); Notifications.Notifications.Add(popupModel); } NotifyList.NotifyPanel?.panelList.Children.Insert(0, popup); popup.Margin = new Thickness(0, 0, 0, 20); popup.ClickClose += Popup_ClickClose; } await Task.Delay(100); } }
private static async void Close(PopupNotify popup) { popup.ClickClose -= Popup_ClickClose; popup.BeginAnimation(UserControl.OpacityProperty, Hide); Notifications.Notifications.Remove(popup.notifyModel); await Task.Delay(Hide.Duration.TimeSpan); UIElementCollection collection = NotifyList.NotifyPanel?.panelList.Children; NotifyList.NotifyPanel?.panelList.Children.Remove(popup); }
public static void CloseAll() { while (NotifyList.NotifyPanel?.panelList.Children.Count > 0) { PopupNotify popup = (PopupNotify)NotifyList.NotifyPanel?.panelList.Children[0]; popup.ClickClose -= Popup_ClickClose; Notifications.Notifications.Remove(popup.notifyModel); NotifyList.NotifyPanel?.panelList.Children.Remove(popup); } }
private static void Load() { Notifications = Notifications.Load <NotificationsModel>(DefaultPaths.PathToLocal + "Notifications.json"); foreach (NotifyModel notify in Notifications.Notifications) { PopupNotify popup = new PopupNotify(notify); NotifyList.NotifyPanel?.panelList.Children.Insert(0, popup); popup.Margin = new Thickness(0, 0, 0, 20); popup.ClickClose += Popup_ClickClose; } }
private async static void Close(PopupNotify popup) { popup.ClickClose -= Popup_ClickClose; popup.BeginAnimation(UserControl.OpacityProperty, Hide); await Task.Delay(Hide.Duration.TimeSpan); UIElementCollection collection = NotifyList.NotifyPanel?.panelList.Children; if (collection.Count > 0 && (PopupNotify)collection[0] == popup) { run = false; } NotifyList.NotifyPanel?.panelList.Children.Remove(popup); Show(); }
public void OnShowNotification(NotificacionesLogModel notifCliente) { PopupNotify p = new PopupNotify(); p.WaitTime = 0; p.Title = string.Format("[{0}] {1}", notifCliente.Aplicacion, notifCliente.Titulo); p.Message = notifCliente.Nota; p.Link = notifCliente.Link; p.ShowForever = true; p.NotiLogId = notifCliente.IdNotificacionLog; p.OnCloseNotification += p_OnCloseNotification; p.OnNotificationShown += p_OnNotificationShown; p.WaitOnMouseOver = true; this.Invoke(new MethodInvoker(() => { p.Show(); })); }
private async static void Show() { while (NotifyList.NotifyPanel?.panelList.Children.Count < 2 && popupNotifies.Count != 0) { PopupNotify popup = popupNotifies.Dequeue(); NotifyList.NotifyPanel?.panelList.Children.Add(popup); popup.Margin = new System.Windows.Thickness(0, 0, 0, 10); popup.ClickClose += Popup_ClickClose; } if (run) { return; } run = true; if (NotifyList.NotifyPanel?.panelList.Children.Count != 0) { PopupNotify popup = (PopupNotify)NotifyList.NotifyPanel?.panelList.Children[0]; await Task.Delay(popup.DelayMs); Close(popup); } }