2017-08-02 10:13:23 +02:00
|
|
|
|
/*
|
2019-01-09 11:25:21 +01:00
|
|
|
|
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
2017-08-02 10:13:23 +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/.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-08-30 09:55:26 +02:00
|
|
|
|
using SafeExamBrowser.Client.Contracts;
|
|
|
|
|
using SafeExamBrowser.Configuration.Contracts;
|
|
|
|
|
using SafeExamBrowser.UserInterface.Contracts;
|
|
|
|
|
using SafeExamBrowser.UserInterface.Contracts.Shell;
|
|
|
|
|
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
2017-08-02 10:13:23 +02:00
|
|
|
|
|
2018-01-18 08:16:20 +01:00
|
|
|
|
namespace SafeExamBrowser.Client.Notifications
|
2017-08-02 10:13:23 +02:00
|
|
|
|
{
|
2018-01-18 08:16:20 +01:00
|
|
|
|
internal class AboutNotificationController : INotificationController
|
2017-08-02 10:13:23 +02:00
|
|
|
|
{
|
2019-03-08 11:43:52 +01:00
|
|
|
|
private INotificationControl notification;
|
2018-06-29 09:50:20 +02:00
|
|
|
|
private AppConfig appConfig;
|
2017-08-02 10:13:23 +02:00
|
|
|
|
private IUserInterfaceFactory uiFactory;
|
|
|
|
|
private IWindow window;
|
|
|
|
|
|
2018-06-29 09:50:20 +02:00
|
|
|
|
public AboutNotificationController(AppConfig appConfig, IUserInterfaceFactory uiFactory)
|
2017-08-02 10:13:23 +02:00
|
|
|
|
{
|
2018-06-29 09:50:20 +02:00
|
|
|
|
this.appConfig = appConfig;
|
2017-08-02 10:13:23 +02:00
|
|
|
|
this.uiFactory = uiFactory;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-08 11:43:52 +01:00
|
|
|
|
public void RegisterNotification(INotificationControl notification)
|
2017-08-02 10:13:23 +02:00
|
|
|
|
{
|
|
|
|
|
this.notification = notification;
|
|
|
|
|
|
|
|
|
|
notification.Clicked += Notification_Clicked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Terminate()
|
|
|
|
|
{
|
|
|
|
|
window?.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Notification_Clicked()
|
|
|
|
|
{
|
|
|
|
|
if (window == null)
|
|
|
|
|
{
|
2018-06-29 09:50:20 +02:00
|
|
|
|
window = uiFactory.CreateAboutWindow(appConfig);
|
2017-08-02 10:13:23 +02:00
|
|
|
|
|
|
|
|
|
window.Closing += () => window = null;
|
|
|
|
|
window.Show();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
window.BringToForeground();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|