2017-08-02 10:13:23 +02:00
|
|
|
|
/*
|
2018-01-16 08:24:00 +01:00
|
|
|
|
* Copyright (c) 2018 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/.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using SafeExamBrowser.Contracts.Behaviour;
|
2018-01-17 14:08:39 +01:00
|
|
|
|
using SafeExamBrowser.Contracts.Configuration;
|
2017-08-02 10:13:23 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.Configuration.Settings;
|
|
|
|
|
using SafeExamBrowser.Contracts.I18n;
|
|
|
|
|
using SafeExamBrowser.Contracts.UserInterface;
|
2017-08-15 15:30:31 +02:00
|
|
|
|
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
|
2017-08-02 10:13:23 +02:00
|
|
|
|
|
|
|
|
|
namespace SafeExamBrowser.Core.Notifications
|
|
|
|
|
{
|
|
|
|
|
public class AboutNotificationController : INotificationController
|
|
|
|
|
{
|
2017-08-15 15:30:31 +02:00
|
|
|
|
private INotificationButton notification;
|
2018-01-17 14:08:39 +01:00
|
|
|
|
private IRuntimeInfo runtimeInfo;
|
2017-08-02 10:13:23 +02:00
|
|
|
|
private IText text;
|
|
|
|
|
private IUserInterfaceFactory uiFactory;
|
|
|
|
|
private IWindow window;
|
|
|
|
|
|
2018-01-17 14:08:39 +01:00
|
|
|
|
public AboutNotificationController(IRuntimeInfo runtimeInfo, IText text, IUserInterfaceFactory uiFactory)
|
2017-08-02 10:13:23 +02:00
|
|
|
|
{
|
2018-01-17 14:08:39 +01:00
|
|
|
|
this.runtimeInfo = runtimeInfo;
|
2017-08-02 10:13:23 +02:00
|
|
|
|
this.text = text;
|
|
|
|
|
this.uiFactory = uiFactory;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 15:30:31 +02:00
|
|
|
|
public void RegisterNotification(INotificationButton 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-01-17 14:08:39 +01:00
|
|
|
|
window = uiFactory.CreateAboutWindow(runtimeInfo, text);
|
2017-08-02 10:13:23 +02:00
|
|
|
|
|
|
|
|
|
window.Closing += () => window = null;
|
|
|
|
|
window.Show();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
window.BringToForeground();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|