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

62 lines
1.7 KiB
C#
Raw Normal View History

2017-08-02 10:13:23 +02:00
/*
* Copyright (c) 2023 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 System;
using SafeExamBrowser.Configuration.Contracts;
using SafeExamBrowser.Core.Contracts.Notifications;
using SafeExamBrowser.Core.Contracts.Notifications.Events;
using SafeExamBrowser.Core.Contracts.Resources.Icons;
using SafeExamBrowser.I18n.Contracts;
using SafeExamBrowser.UserInterface.Contracts;
using SafeExamBrowser.UserInterface.Contracts.Windows;
2017-08-02 10:13:23 +02:00
namespace SafeExamBrowser.Client.Notifications
2017-08-02 10:13:23 +02:00
{
internal class AboutNotification : INotification
2017-08-02 10:13:23 +02:00
{
private readonly AppConfig appConfig;
private readonly IUserInterfaceFactory uiFactory;
2017-08-02 10:13:23 +02:00
private IWindow window;
public string Tooltip { get; }
public IconResource IconResource { get; }
public event NotificationChangedEventHandler NotificationChanged { add { } remove { } }
public AboutNotification(AppConfig appConfig, IText text, IUserInterfaceFactory uiFactory)
2017-08-02 10:13:23 +02:00
{
this.appConfig = appConfig;
2017-08-02 10:13:23 +02:00
this.uiFactory = uiFactory;
IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/AboutNotification.xaml") };
Tooltip = text.Get(TextKey.Notification_AboutTooltip);
2017-08-02 10:13:23 +02:00
}
public void Activate()
2017-08-02 10:13:23 +02:00
{
if (window == default)
2017-08-02 10:13:23 +02:00
{
window = uiFactory.CreateAboutWindow(appConfig);
2017-08-02 10:13:23 +02:00
window.Closed += () => window = default;
2017-08-02 10:13:23 +02:00
window.Show();
}
else
{
window.BringToForeground();
}
}
public void Terminate()
{
window?.Close();
}
2017-08-02 10:13:23 +02:00
}
}