2017-08-22 10:29:00 +02:00
|
|
|
|
/*
|
2024-03-05 18:37:42 +01:00
|
|
|
|
* Copyright (c) 2024 ETH Zürich, IT Services
|
2017-08-22 10:29:00 +02:00
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
2021-03-18 23:12:07 +01:00
|
|
|
|
using SafeExamBrowser.Core.Contracts.Notifications;
|
2019-08-30 09:55:26 +02:00
|
|
|
|
using SafeExamBrowser.UserInterface.Contracts.Shell;
|
2019-05-08 09:56:34 +02:00
|
|
|
|
using SafeExamBrowser.UserInterface.Shared.Utilities;
|
2017-08-22 10:29:00 +02:00
|
|
|
|
|
2020-03-16 18:29:06 +01:00
|
|
|
|
namespace SafeExamBrowser.UserInterface.Desktop.Controls.ActionCenter
|
2017-08-22 10:29:00 +02:00
|
|
|
|
{
|
2020-03-16 18:29:06 +01:00
|
|
|
|
internal partial class NotificationButton : UserControl, INotificationControl
|
2017-08-22 10:29:00 +02:00
|
|
|
|
{
|
2023-03-24 18:18:02 +01:00
|
|
|
|
private readonly INotification notification;
|
2017-08-22 10:29:00 +02:00
|
|
|
|
|
2021-03-18 23:12:07 +01:00
|
|
|
|
internal NotificationButton(INotification notification)
|
2017-08-22 10:29:00 +02:00
|
|
|
|
{
|
2021-03-18 23:12:07 +01:00
|
|
|
|
this.notification = notification;
|
2019-09-04 14:11:19 +02:00
|
|
|
|
|
2017-08-22 10:29:00 +02:00
|
|
|
|
InitializeComponent();
|
2021-03-18 23:12:07 +01:00
|
|
|
|
InitializeNotification();
|
2021-03-25 13:49:45 +01:00
|
|
|
|
UpdateNotification();
|
2017-08-22 10:29:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-04 14:11:19 +02:00
|
|
|
|
private void IconButton_Click(object sender, RoutedEventArgs e)
|
2017-08-22 10:29:00 +02:00
|
|
|
|
{
|
2024-02-23 18:32:44 +01:00
|
|
|
|
if (notification.CanActivate)
|
|
|
|
|
{
|
|
|
|
|
notification.Activate();
|
|
|
|
|
}
|
2017-08-22 10:29:00 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-18 23:12:07 +01:00
|
|
|
|
private void InitializeNotification()
|
2021-03-25 13:49:45 +01:00
|
|
|
|
{
|
|
|
|
|
notification.NotificationChanged += () => Dispatcher.Invoke(UpdateNotification);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void UpdateNotification()
|
2017-08-22 10:29:00 +02:00
|
|
|
|
{
|
2021-03-18 23:12:07 +01:00
|
|
|
|
Icon.Content = IconResourceLoader.Load(notification.IconResource);
|
2024-02-23 18:32:44 +01:00
|
|
|
|
IconButton.IsEnabled = notification.CanActivate;
|
2021-03-18 23:12:07 +01:00
|
|
|
|
IconButton.ToolTip = notification.Tooltip;
|
|
|
|
|
Text.Text = notification.Tooltip;
|
2017-08-22 10:29:00 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|