public static void FetchNotification(MainForm f) { if (Count < 0) Count = 0; if (Queued.Count != 0) { NotificationType n = Queued.Dequeue(); byte[] bytes = Encoding.Default.GetBytes(n.Control.Title); n.Control.Title = Encoding.UTF8.GetString(bytes); bytes = Encoding.Default.GetBytes(n.Control.Desc); n.Control.Desc = Encoding.UTF8.GetString(bytes); Notification notification = new Notification(f, n.Tag, n.Control.Image, n.Control.Title, n.Control.Desc, n.Link, !n.ShowInWindow); if (n.Type == 0) { if (OnGenericMessage != null) OnGenericMessage(n.Tag, notification); } else if (n.Type == 1) { if (OnYouTubeMessage != null) OnYouTubeMessage(n.Tag, new NotificationYoutube() { N = notification, Yt = ((YoutubeNotificationType)n).ID }); } else if (n.Type == 2) { if (OnFacebookMessage != null) OnFacebookMessage(n.Tag, new NotificationFacebook() { N = notification, Fb = ((FacebookNotificationType)n).Data }); } if (n.ShowInWindow) { if (DateTime.Now > Allow && Count <= Config.Settings.MaxNotifications && ShowNow) { notification.ShowInTaskbar = false; notification.Show(); notification.Left = Screen.PrimaryScreen.Bounds.Width - 375; if (SystemInformation.WorkingArea.Top > 0) notification.Top = Screen.PrimaryScreen.Bounds.Height - 100 * Count - 105; else notification.Top = Screen.PrimaryScreen.Bounds.Height - 100 * Count - 105 - GetTaskbarHeight(); Count++; notification.Opacity = 1; } } } }
private void OnGenericMessage(object sender, Notification ev) { #if R try { #endif string s = sender.ToString(); Controls.NotifyList n = GetList(s); if (n != null) { List<Control> cs = new List<Control>(); foreach (Control c in n.GetControls()) { if (c is Controls.NotificationControl) { Controls.NotificationControl con = ev.ToControl(); if (con.title == ((Controls.NotificationControl)c).title && con.desc == ((Controls.NotificationControl)c).desc) return; } cs.Add(c); } n.GetControls().Clear(); n.AddGenericNotification(ev); n.GetControls().AddRange(cs.ToArray()); n.AddGenericNotification(null); } #if R } catch (Exception e) { ThrowError(e); } #endif }