seb-win-refactoring/SafeExamBrowser.Client/Notifications/LogNotificationController.cs

60 lines
1.4 KiB
C#
Raw Normal View History

2017-08-07 12:23:56 +02:00
/*
* Copyright (c) 2018 ETH Zürich, Educational Development and Technology (LET)
2017-08-07 12:23:56 +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;
using SafeExamBrowser.Contracts.I18n;
using SafeExamBrowser.Contracts.Logging;
using SafeExamBrowser.Contracts.UserInterface;
using SafeExamBrowser.Contracts.UserInterface.Taskbar;
2017-08-07 12:23:56 +02:00
namespace SafeExamBrowser.Client.Notifications
2017-08-07 12:23:56 +02:00
{
internal class LogNotificationController : INotificationController
2017-08-07 12:23:56 +02:00
{
private INotificationButton notification;
2017-08-07 12:23:56 +02:00
private ILogger logger;
private IText text;
private IUserInterfaceFactory uiFactory;
private IWindow window;
public LogNotificationController(ILogger logger, IText text, IUserInterfaceFactory uiFactory)
2017-08-07 12:23:56 +02:00
{
this.logger = logger;
this.text = text;
this.uiFactory = uiFactory;
}
public void RegisterNotification(INotificationButton notification)
2017-08-07 12:23:56 +02:00
{
this.notification = notification;
notification.Clicked += Notification_Clicked;
}
public void Terminate()
{
window?.Close();
}
private void Notification_Clicked()
{
if (window == null)
{
window = uiFactory.CreateLogWindow(logger, text);
2017-08-07 12:23:56 +02:00
window.Closing += () => window = null;
window.Show();
}
else
{
window.BringToForeground();
}
}
}
}