From 0777644f0e9e37e9f5ed4ec83187f0faaa13a148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20B=C3=BCchel?= Date: Fri, 23 Feb 2024 18:32:44 +0100 Subject: [PATCH] SEBSP-107: Added property to control activation of notifications and created placeholder for screen proctoring notification icons. --- .../Notifications/AboutNotification.cs | 2 ++ .../Notifications/LogNotification.cs | 2 ++ .../Notifications/INotification.cs | 11 ++++++++--- .../JitsiMeet/JitsiMeetImplementation.cs | 8 ++++++-- .../ProctoringImplementation.cs | 1 + .../ScreenProctoringImplementation.cs | 8 +++----- .../Controls/ActionCenter/NotificationButton.xaml | 2 +- .../Controls/ActionCenter/NotificationButton.xaml.cs | 6 +++++- .../Controls/Taskbar/NotificationButton.xaml | 3 ++- .../Controls/Taskbar/NotificationButton.xaml.cs | 8 ++++++-- ...tification_Active.xaml => Proctoring_Active.xaml} | 0 ...cation_Inactive.xaml => Proctoring_Inactive.xaml} | 0 .../Images/ScreenProctoring_Active.xaml | 11 +++++++++++ .../Images/ScreenProctoring_Inactive.xaml | 11 +++++++++++ .../SafeExamBrowser.UserInterface.Desktop.csproj | 12 ++++++++++-- .../Controls/ActionCenter/NotificationButton.xaml | 2 +- .../Controls/ActionCenter/NotificationButton.xaml.cs | 6 +++++- .../Controls/Taskbar/NotificationButton.xaml | 3 ++- .../Controls/Taskbar/NotificationButton.xaml.cs | 8 ++++++-- 19 files changed, 82 insertions(+), 22 deletions(-) rename SafeExamBrowser.UserInterface.Desktop/Images/{ProctoringNotification_Active.xaml => Proctoring_Active.xaml} (100%) rename SafeExamBrowser.UserInterface.Desktop/Images/{ProctoringNotification_Inactive.xaml => Proctoring_Inactive.xaml} (100%) create mode 100644 SafeExamBrowser.UserInterface.Desktop/Images/ScreenProctoring_Active.xaml create mode 100644 SafeExamBrowser.UserInterface.Desktop/Images/ScreenProctoring_Inactive.xaml diff --git a/SafeExamBrowser.Client/Notifications/AboutNotification.cs b/SafeExamBrowser.Client/Notifications/AboutNotification.cs index 450820ba..11490edf 100644 --- a/SafeExamBrowser.Client/Notifications/AboutNotification.cs +++ b/SafeExamBrowser.Client/Notifications/AboutNotification.cs @@ -24,6 +24,7 @@ namespace SafeExamBrowser.Client.Notifications private IWindow window; + public bool CanActivate { get; } public string Tooltip { get; } public IconResource IconResource { get; } @@ -34,6 +35,7 @@ namespace SafeExamBrowser.Client.Notifications this.appConfig = appConfig; this.uiFactory = uiFactory; + CanActivate = true; IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/AboutNotification.xaml") }; Tooltip = text.Get(TextKey.Notification_AboutTooltip); } diff --git a/SafeExamBrowser.Client/Notifications/LogNotification.cs b/SafeExamBrowser.Client/Notifications/LogNotification.cs index 9864f9cd..3a3c37a2 100644 --- a/SafeExamBrowser.Client/Notifications/LogNotification.cs +++ b/SafeExamBrowser.Client/Notifications/LogNotification.cs @@ -24,6 +24,7 @@ namespace SafeExamBrowser.Client.Notifications private IWindow window; + public bool CanActivate { get; } public string Tooltip { get; } public IconResource IconResource { get; } @@ -34,6 +35,7 @@ namespace SafeExamBrowser.Client.Notifications this.logger = logger; this.uiFactory = uiFactory; + CanActivate = true; IconResource = new BitmapIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/LogNotification.ico") }; Tooltip = text.Get(TextKey.Notification_LogTooltip); } diff --git a/SafeExamBrowser.Core.Contracts/Notifications/INotification.cs b/SafeExamBrowser.Core.Contracts/Notifications/INotification.cs index 1afb16d0..592086f3 100644 --- a/SafeExamBrowser.Core.Contracts/Notifications/INotification.cs +++ b/SafeExamBrowser.Core.Contracts/Notifications/INotification.cs @@ -17,15 +17,20 @@ namespace SafeExamBrowser.Core.Contracts.Notifications public interface INotification { /// - /// The tooltip for the notification. + /// Determines whether the notification can be activated. /// - string Tooltip { get; } + bool CanActivate { get; } /// /// The resource providing the notification icon. /// IconResource IconResource { get; } + /// + /// The tooltip for the notification. + /// + string Tooltip { get; } + /// /// Event fired when the notification has changed. /// @@ -35,7 +40,7 @@ namespace SafeExamBrowser.Core.Contracts.Notifications /// Executes the notification functionality. /// void Activate(); - + /// /// Terminates the notification functionality and release all used resources. /// diff --git a/SafeExamBrowser.Proctoring/JitsiMeet/JitsiMeetImplementation.cs b/SafeExamBrowser.Proctoring/JitsiMeet/JitsiMeetImplementation.cs index 83984a88..4bc3f8f5 100644 --- a/SafeExamBrowser.Proctoring/JitsiMeet/JitsiMeetImplementation.cs +++ b/SafeExamBrowser.Proctoring/JitsiMeet/JitsiMeetImplementation.cs @@ -245,15 +245,19 @@ namespace SafeExamBrowser.Proctoring.JitsiMeet private void ShowNotificationActive() { - IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/ProctoringNotification_Active.xaml") }; + CanActivate = true; + IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Proctoring_Active.xaml") }; Tooltip = text.Get(TextKey.Notification_ProctoringActiveTooltip); + NotificationChanged?.Invoke(); } private void ShowNotificationInactive() { - IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/ProctoringNotification_Inactive.xaml") }; + CanActivate = false; + IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/Proctoring_Inactive.xaml") }; Tooltip = text.Get(TextKey.Notification_ProctoringInactiveTooltip); + NotificationChanged?.Invoke(); } } diff --git a/SafeExamBrowser.Proctoring/ProctoringImplementation.cs b/SafeExamBrowser.Proctoring/ProctoringImplementation.cs index 9252c3aa..48e1e7eb 100644 --- a/SafeExamBrowser.Proctoring/ProctoringImplementation.cs +++ b/SafeExamBrowser.Proctoring/ProctoringImplementation.cs @@ -17,6 +17,7 @@ namespace SafeExamBrowser.Proctoring { internal abstract string Name { get; } + public bool CanActivate { get; protected set; } public string Tooltip { get; protected set; } public IconResource IconResource { get; protected set; } diff --git a/SafeExamBrowser.Proctoring/ScreenProctoring/ScreenProctoringImplementation.cs b/SafeExamBrowser.Proctoring/ScreenProctoring/ScreenProctoringImplementation.cs index b10cdbe7..f09e86a1 100644 --- a/SafeExamBrowser.Proctoring/ScreenProctoring/ScreenProctoringImplementation.cs +++ b/SafeExamBrowser.Proctoring/ScreenProctoring/ScreenProctoringImplementation.cs @@ -176,18 +176,16 @@ namespace SafeExamBrowser.Proctoring.ScreenProctoring private void UpdateNotification(bool live) { - // TODO: Replace with actual icon! - // TODO: Extend INotification with IsEnabled or CanActivate! - // TODO: Service health, HD space and caching indicators! + CanActivate = false; if (live) { - IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/ProctoringNotification_Active.xaml") }; + IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/ScreenProctoring_Active.xaml") }; Tooltip = text.Get(TextKey.Notification_ProctoringActiveTooltip); } else { - IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/ProctoringNotification_Inactive.xaml") }; + IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/ScreenProctoring_Inactive.xaml") }; Tooltip = text.Get(TextKey.Notification_ProctoringInactiveTooltip); } diff --git a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NotificationButton.xaml b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NotificationButton.xaml index 1d8cfcc4..345223d6 100644 --- a/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NotificationButton.xaml +++ b/SafeExamBrowser.UserInterface.Desktop/Controls/ActionCenter/NotificationButton.xaml @@ -14,7 +14,7 @@ -