Restore SEBPatch
This commit is contained in:
63
SafeExamBrowser.Client/Notifications/AboutNotification.cs
Normal file
63
SafeExamBrowser.Client/Notifications/AboutNotification.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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;
|
||||
|
||||
namespace SafeExamBrowser.Client.Notifications
|
||||
{
|
||||
internal class AboutNotification : INotification
|
||||
{
|
||||
private readonly AppConfig appConfig;
|
||||
private readonly IUserInterfaceFactory uiFactory;
|
||||
|
||||
private IWindow window;
|
||||
|
||||
public bool CanActivate { get; }
|
||||
public string Tooltip { get; }
|
||||
public IconResource IconResource { get; }
|
||||
|
||||
public event NotificationChangedEventHandler NotificationChanged { add { } remove { } }
|
||||
|
||||
public AboutNotification(AppConfig appConfig, IText text, IUserInterfaceFactory uiFactory)
|
||||
{
|
||||
this.appConfig = appConfig;
|
||||
this.uiFactory = uiFactory;
|
||||
|
||||
CanActivate = true;
|
||||
IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/AboutNotification.xaml") };
|
||||
Tooltip = text.Get(TextKey.Notification_AboutTooltip);
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
if (window == default)
|
||||
{
|
||||
window = uiFactory.CreateAboutWindow(appConfig);
|
||||
|
||||
window.Closed += () => window = default;
|
||||
window.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
window.BringToForeground();
|
||||
}
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{
|
||||
window?.Close();
|
||||
}
|
||||
}
|
||||
}
|
63
SafeExamBrowser.Client/Notifications/LogNotification.cs
Normal file
63
SafeExamBrowser.Client/Notifications/LogNotification.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2024 ETH Zürich, IT Services
|
||||
*
|
||||
* 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.Core.Contracts.Notifications;
|
||||
using SafeExamBrowser.Core.Contracts.Notifications.Events;
|
||||
using SafeExamBrowser.Core.Contracts.Resources.Icons;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.UserInterface.Contracts;
|
||||
using SafeExamBrowser.UserInterface.Contracts.Windows;
|
||||
|
||||
namespace SafeExamBrowser.Client.Notifications
|
||||
{
|
||||
internal class LogNotification : INotification
|
||||
{
|
||||
private readonly ILogger logger;
|
||||
private readonly IUserInterfaceFactory uiFactory;
|
||||
|
||||
private IWindow window;
|
||||
|
||||
public bool CanActivate { get; }
|
||||
public string Tooltip { get; }
|
||||
public IconResource IconResource { get; }
|
||||
|
||||
public event NotificationChangedEventHandler NotificationChanged { add { } remove { } }
|
||||
|
||||
public LogNotification(ILogger logger, IText text, IUserInterfaceFactory uiFactory)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.uiFactory = uiFactory;
|
||||
|
||||
CanActivate = true;
|
||||
IconResource = new BitmapIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/LogNotification.ico") };
|
||||
Tooltip = text.Get(TextKey.Notification_LogTooltip);
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
if (window == default)
|
||||
{
|
||||
window = uiFactory.CreateLogWindow(logger);
|
||||
|
||||
window.Closed += () => window = default;
|
||||
window.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
window.BringToForeground();
|
||||
}
|
||||
}
|
||||
|
||||
public void Terminate()
|
||||
{
|
||||
window?.Close();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user