From 569ad6fd7a3944b970fd08e715c8107a14ae117b Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 25 Feb 2017 14:32:02 -0500 Subject: [PATCH] Fire event when note is marked read --- ShiftOS.WinForms/Applications/Notifications.cs | 7 +++++++ ShiftOS.WinForms/WinformsDesktop.cs | 7 +++++++ ShiftOS_TheReturn/NotificationDaemon.cs | 2 ++ 3 files changed, 16 insertions(+) diff --git a/ShiftOS.WinForms/Applications/Notifications.cs b/ShiftOS.WinForms/Applications/Notifications.cs index 6fb659d..540d2b5 100644 --- a/ShiftOS.WinForms/Applications/Notifications.cs +++ b/ShiftOS.WinForms/Applications/Notifications.cs @@ -23,9 +23,14 @@ namespace ShiftOS.WinForms.Applications { SetupUI(); }; + onRead += () => + { + SetupUI(); + }; } Action onMade = null; + Action onRead = null; public void SetupUI() { @@ -227,6 +232,7 @@ namespace ShiftOS.WinForms.Applications { SetupUI(); NotificationDaemon.NotificationMade += onMade; + NotificationDaemon.NotificationRead += onRead; } public void OnSkinLoad() @@ -236,6 +242,7 @@ namespace ShiftOS.WinForms.Applications public bool OnUnload() { NotificationDaemon.NotificationMade -= onMade; + NotificationDaemon.NotificationRead -= onRead; return true; } diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index 957c793..bcb853f 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -68,6 +68,13 @@ namespace ShiftOS.WinForms }; + NotificationDaemon.NotificationRead += () => + { + //Soon this will pop a balloon note. + btnnotifications.Text = "Notifications (" + NotificationDaemon.GetUnreadCount().ToString() + ")"; + + }; + this.LocationChanged += (o, a) => { if (this.Left != 0) diff --git a/ShiftOS_TheReturn/NotificationDaemon.cs b/ShiftOS_TheReturn/NotificationDaemon.cs index 3ea8a54..c6ba90a 100644 --- a/ShiftOS_TheReturn/NotificationDaemon.cs +++ b/ShiftOS_TheReturn/NotificationDaemon.cs @@ -35,6 +35,7 @@ namespace ShiftOS.Engine NotificationMade?.Invoke(lst[lst.Count - 1]); } + public static event Action NotificationRead; public static void MarkRead(int note) { @@ -44,6 +45,7 @@ namespace ShiftOS.Engine notes[note].Read = true; WriteNotes(notes); + NotificationRead?.Invoke(); } public static int GetUnreadCount()