2019-01-11 08:25:40 +01:00
|
|
|
|
/*
|
2024-03-05 18:37:42 +01:00
|
|
|
|
* Copyright (c) 2024 ETH Zürich, IT Services
|
2019-01-11 08:25:40 +01: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-09-06 09:39:28 +02:00
|
|
|
|
using SafeExamBrowser.Settings;
|
|
|
|
|
using SafeExamBrowser.Settings.UserInterface;
|
2019-01-11 08:25:40 +01:00
|
|
|
|
|
2019-12-20 10:03:47 +01:00
|
|
|
|
namespace SafeExamBrowser.Configuration.ConfigurationData.DataMapping
|
2019-01-11 08:25:40 +01:00
|
|
|
|
{
|
2019-12-20 10:03:47 +01:00
|
|
|
|
internal class UserInterfaceDataMapper : BaseDataMapper
|
2019-01-11 08:25:40 +01:00
|
|
|
|
{
|
2019-12-20 10:03:47 +01:00
|
|
|
|
internal override void Map(string key, object value, AppSettings settings)
|
|
|
|
|
{
|
|
|
|
|
switch (key)
|
|
|
|
|
{
|
2020-02-19 11:53:29 +01:00
|
|
|
|
case Keys.UserInterface.ActionCenter.EnableActionCenter:
|
|
|
|
|
MapEnableActionCenter(settings, value);
|
|
|
|
|
break;
|
2024-01-11 17:35:52 +01:00
|
|
|
|
case Keys.UserInterface.SystemControls.Audio.Show:
|
2020-02-19 11:53:29 +01:00
|
|
|
|
MapShowAudio(settings, value);
|
|
|
|
|
break;
|
2024-01-11 17:35:52 +01:00
|
|
|
|
case Keys.UserInterface.SystemControls.Clock.Show:
|
2020-02-19 11:53:29 +01:00
|
|
|
|
MapShowClock(settings, value);
|
2019-12-20 10:03:47 +01:00
|
|
|
|
break;
|
2024-01-11 17:35:52 +01:00
|
|
|
|
case Keys.UserInterface.SystemControls.KeyboardLayout.Show:
|
2020-02-19 11:53:29 +01:00
|
|
|
|
MapShowKeyboardLayout(settings, value);
|
2019-12-20 10:03:47 +01:00
|
|
|
|
break;
|
2024-01-11 17:35:52 +01:00
|
|
|
|
case Keys.UserInterface.SystemControls.Network.Show:
|
2022-04-19 18:21:29 +02:00
|
|
|
|
MapShowNetwork(settings, value);
|
2019-12-20 10:03:47 +01:00
|
|
|
|
break;
|
2024-01-11 17:35:52 +01:00
|
|
|
|
case Keys.UserInterface.SystemControls.PowerSupply.ChargeThresholdCritical:
|
|
|
|
|
MapChargeThresholdCritical(settings, value);
|
|
|
|
|
break;
|
|
|
|
|
case Keys.UserInterface.SystemControls.PowerSupply.ChargeThresholdLow:
|
|
|
|
|
MapChargeThresholdLow(settings, value);
|
|
|
|
|
break;
|
2020-02-19 11:53:29 +01:00
|
|
|
|
case Keys.UserInterface.Taskbar.EnableTaskbar:
|
|
|
|
|
MapEnableTaskbar(settings, value);
|
|
|
|
|
break;
|
|
|
|
|
case Keys.UserInterface.Taskbar.ShowApplicationLog:
|
|
|
|
|
MapShowApplicationLog(settings, value);
|
2019-12-20 10:03:47 +01:00
|
|
|
|
break;
|
|
|
|
|
case Keys.UserInterface.UserInterfaceMode:
|
|
|
|
|
MapUserInterfaceMode(settings, value);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-19 11:53:29 +01:00
|
|
|
|
private void MapEnableActionCenter(AppSettings settings, object value)
|
2019-01-11 09:16:14 +01:00
|
|
|
|
{
|
2020-02-19 11:53:29 +01:00
|
|
|
|
if (value is bool enable)
|
2019-01-11 09:16:14 +01:00
|
|
|
|
{
|
2020-02-19 11:53:29 +01:00
|
|
|
|
settings.ActionCenter.EnableActionCenter = enable;
|
2019-01-11 09:16:14 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-19 11:53:29 +01:00
|
|
|
|
private void MapShowAudio(AppSettings settings, object value)
|
2019-08-15 10:46:47 +02:00
|
|
|
|
{
|
|
|
|
|
if (value is bool show)
|
|
|
|
|
{
|
|
|
|
|
settings.ActionCenter.ShowAudio = show;
|
|
|
|
|
settings.Taskbar.ShowAudio = show;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-19 11:53:29 +01:00
|
|
|
|
private void MapShowClock(AppSettings settings, object value)
|
2019-01-11 08:25:40 +01:00
|
|
|
|
{
|
|
|
|
|
if (value is bool show)
|
|
|
|
|
{
|
2019-03-29 09:14:54 +01:00
|
|
|
|
settings.ActionCenter.ShowClock = show;
|
2019-01-11 08:25:40 +01:00
|
|
|
|
settings.Taskbar.ShowClock = show;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-19 11:53:29 +01:00
|
|
|
|
private void MapShowKeyboardLayout(AppSettings settings, object value)
|
2019-01-11 08:25:40 +01:00
|
|
|
|
{
|
2019-03-29 09:14:54 +01:00
|
|
|
|
if (value is bool show)
|
2019-01-11 08:25:40 +01:00
|
|
|
|
{
|
2019-03-29 09:14:54 +01:00
|
|
|
|
settings.ActionCenter.ShowKeyboardLayout = show;
|
|
|
|
|
settings.Taskbar.ShowKeyboardLayout = show;
|
2019-01-11 08:25:40 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-19 18:21:29 +02:00
|
|
|
|
private void MapShowNetwork(AppSettings settings, object value)
|
2019-01-11 08:25:40 +01:00
|
|
|
|
{
|
2019-03-29 09:14:54 +01:00
|
|
|
|
if (value is bool show)
|
2019-01-11 08:25:40 +01:00
|
|
|
|
{
|
2022-04-19 18:21:29 +02:00
|
|
|
|
settings.ActionCenter.ShowNetwork = show;
|
|
|
|
|
settings.Taskbar.ShowNetwork = show;
|
2019-01-11 08:25:40 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-11 17:35:52 +01:00
|
|
|
|
private void MapChargeThresholdCritical(AppSettings settings, object value)
|
|
|
|
|
{
|
|
|
|
|
if (value is double threshold)
|
|
|
|
|
{
|
|
|
|
|
settings.PowerSupply.ChargeThresholdCritical = threshold;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MapChargeThresholdLow(AppSettings settings, object value)
|
|
|
|
|
{
|
|
|
|
|
if (value is double threshold)
|
|
|
|
|
{
|
|
|
|
|
settings.PowerSupply.ChargeThresholdLow = threshold;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-19 11:53:29 +01:00
|
|
|
|
private void MapEnableTaskbar(AppSettings settings, object value)
|
|
|
|
|
{
|
|
|
|
|
if (value is bool enable)
|
|
|
|
|
{
|
|
|
|
|
settings.Taskbar.EnableTaskbar = enable;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void MapShowApplicationLog(AppSettings settings, object value)
|
|
|
|
|
{
|
|
|
|
|
if (value is bool show)
|
|
|
|
|
{
|
|
|
|
|
settings.Taskbar.ShowApplicationLog = show;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-01 11:30:53 +02:00
|
|
|
|
private void MapUserInterfaceMode(AppSettings settings, object value)
|
2019-01-11 08:25:40 +01:00
|
|
|
|
{
|
|
|
|
|
if (value is bool mobile)
|
|
|
|
|
{
|
|
|
|
|
settings.UserInterfaceMode = mobile ? UserInterfaceMode.Mobile : UserInterfaceMode.Desktop;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|