SEBWIN-342: Removed UI dependencies from wireless network system component.

This commit is contained in:
dbuechel 2019-09-04 11:46:30 +02:00
parent dcbdc13338
commit 6f51d266cc
40 changed files with 775 additions and 829 deletions

View file

@ -18,6 +18,7 @@ using SafeExamBrowser.SystemComponents.Contracts;
using SafeExamBrowser.SystemComponents.Contracts.Audio;
using SafeExamBrowser.SystemComponents.Contracts.Keyboard;
using SafeExamBrowser.SystemComponents.Contracts.PowerSupply;
using SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork;
using SafeExamBrowser.UserInterface.Contracts;
using SafeExamBrowser.UserInterface.Contracts.Shell;
using SafeExamBrowser.WindowsApi.Contracts;
@ -40,12 +41,11 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
private Mock<INotificationInfo> logInfo;
private Mock<INotificationController> logController;
private Mock<IPowerSupply> powerSupply;
// TODO
//private Mock<ISystemComponent<ISystemWirelessNetworkControl>> wirelessNetwork;
private Mock<ISystemInfo> systemInfo;
private Mock<ITaskbar> taskbar;
private Mock<IText> text;
private Mock<IUserInterfaceFactory> uiFactory;
private Mock<IWirelessAdapter> wirelessAdapter;
private ShellOperation sut;
@ -63,14 +63,13 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
logInfo = new Mock<INotificationInfo>();
logController = new Mock<INotificationController>();
powerSupply = new Mock<IPowerSupply>();
// TODO
//wirelessNetwork = new Mock<ISystemComponent<ISystemWirelessNetworkControl>>();
systemInfo = new Mock<ISystemInfo>();
taskbar = new Mock<ITaskbar>();
taskbarSettings = new TaskbarSettings();
terminationActivator = new Mock<ITerminationActivator>();
text = new Mock<IText>();
uiFactory = new Mock<IUserInterfaceFactory>();
wirelessAdapter = new Mock<IWirelessAdapter>();
uiFactory.Setup(u => u.CreateNotificationControl(It.IsAny<INotificationInfo>(), It.IsAny<Location>())).Returns(new Mock<INotificationControl>().Object);
@ -86,14 +85,13 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
logInfo.Object,
logController.Object,
powerSupply.Object,
// TODO
//wirelessNetwork.Object,
systemInfo.Object,
taskbar.Object,
taskbarSettings,
terminationActivator.Object,
text.Object,
uiFactory.Object);
uiFactory.Object,
wirelessAdapter.Object);
}
[TestMethod]
@ -201,14 +199,13 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
uiFactory.Setup(f => f.CreateAudioControl(It.IsAny<IAudio>(), It.IsAny<Location>())).Returns(new Mock<ISystemControl>().Object);
uiFactory.Setup(f => f.CreateKeyboardLayoutControl(It.IsAny<IKeyboard>(), It.IsAny<Location>())).Returns(new Mock<ISystemControl>().Object);
uiFactory.Setup(f => f.CreatePowerSupplyControl(It.IsAny<IPowerSupply>(), It.IsAny<Location>())).Returns(new Mock<ISystemControl>().Object);
uiFactory.Setup(f => f.CreateWirelessNetworkControl(It.IsAny<Location>())).Returns(new Mock<ISystemWirelessNetworkControl>().Object);
uiFactory.Setup(f => f.CreateWirelessNetworkControl(It.IsAny<IWirelessAdapter>(), It.IsAny<Location>())).Returns(new Mock<ISystemControl>().Object);
sut.Perform();
audio.Verify(a => a.Initialize(), Times.Once);
powerSupply.Verify(p => p.Initialize(), Times.Once);
// TODO
//wirelessNetwork.Verify(w => w.Initialize(), Times.Once);
wirelessAdapter.Verify(w => w.Initialize(), Times.Once);
keyboard.Verify(k => k.Initialize(), Times.Once);
actionCenter.Verify(a => a.AddSystemControl(It.IsAny<ISystemControl>()), Times.Exactly(4));
taskbar.Verify(t => t.AddSystemControl(It.IsAny<ISystemControl>()), Times.Exactly(4));
@ -230,14 +227,13 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
uiFactory.Setup(f => f.CreateAudioControl(It.IsAny<IAudio>(), It.IsAny<Location>())).Returns(new Mock<ISystemControl>().Object);
uiFactory.Setup(f => f.CreateKeyboardLayoutControl(It.IsAny<IKeyboard>(), It.IsAny<Location>())).Returns(new Mock<ISystemControl>().Object);
uiFactory.Setup(f => f.CreatePowerSupplyControl(It.IsAny<IPowerSupply>(), It.IsAny<Location>())).Returns(new Mock<ISystemControl>().Object);
uiFactory.Setup(f => f.CreateWirelessNetworkControl(It.IsAny<Location>())).Returns(new Mock<ISystemWirelessNetworkControl>().Object);
uiFactory.Setup(f => f.CreateWirelessNetworkControl(It.IsAny<IWirelessAdapter>(), It.IsAny<Location>())).Returns(new Mock<ISystemControl>().Object);
sut.Perform();
audio.Verify(a => a.Initialize(), Times.Once);
powerSupply.Verify(p => p.Initialize(), Times.Once);
// TODO
//wirelessNetwork.Verify(w => w.Initialize(), Times.Once);
wirelessAdapter.Verify(w => w.Initialize(), Times.Once);
keyboard.Verify(k => k.Initialize(), Times.Once);
actionCenter.Verify(a => a.AddSystemControl(It.IsAny<ISystemControl>()), Times.Never);
taskbar.Verify(t => t.AddSystemControl(It.IsAny<ISystemControl>()), Times.Never);
@ -296,8 +292,7 @@ namespace SafeExamBrowser.Client.UnitTests.Operations
logController.Verify(c => c.Terminate(), Times.Once);
powerSupply.Verify(p => p.Terminate(), Times.Once);
keyboard.Verify(k => k.Terminate(), Times.Once);
// TODO
//wirelessNetwork.Verify(w => w.Terminate(), Times.Once);
wirelessAdapter.Verify(w => w.Terminate(), Times.Once);
}
}
}

View file

@ -43,6 +43,7 @@ using SafeExamBrowser.SystemComponents.Audio;
using SafeExamBrowser.SystemComponents.Contracts;
using SafeExamBrowser.SystemComponents.Keyboard;
using SafeExamBrowser.SystemComponents.PowerSupply;
using SafeExamBrowser.SystemComponents.WirelessNetwork;
using SafeExamBrowser.UserInterface.Contracts;
using SafeExamBrowser.UserInterface.Contracts.MessageBox;
using SafeExamBrowser.UserInterface.Contracts.Shell;
@ -263,7 +264,7 @@ namespace SafeExamBrowser.Client
var logInfo = new LogNotificationInfo(text);
var logController = new LogNotificationController(logger, uiFactory);
var powerSupply = new PowerSupply(new ModuleLogger(logger, nameof(PowerSupply)));
var wirelessNetwork = new WirelessNetwork(new ModuleLogger(logger, nameof(WirelessNetwork)), text);
var wirelessAdapter = new WirelessAdapter(new ModuleLogger(logger, nameof(WirelessAdapter)), text);
var activators = new IActionCenterActivator[]
{
new KeyboardActivator(new ModuleLogger(logger, nameof(KeyboardActivator))),
@ -281,14 +282,13 @@ namespace SafeExamBrowser.Client
logInfo,
logController,
powerSupply,
// TODO
//wirelessNetwork,
systemInfo,
taskbar,
configuration.Settings.Taskbar,
terminationActivator,
text,
uiFactory);
uiFactory,
wirelessAdapter);
return operation;
}

View file

@ -17,6 +17,7 @@ using SafeExamBrowser.SystemComponents.Contracts;
using SafeExamBrowser.SystemComponents.Contracts.Audio;
using SafeExamBrowser.SystemComponents.Contracts.Keyboard;
using SafeExamBrowser.SystemComponents.Contracts.PowerSupply;
using SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork;
using SafeExamBrowser.UserInterface.Contracts;
using SafeExamBrowser.UserInterface.Contracts.Shell;
using SafeExamBrowser.WindowsApi.Contracts;
@ -36,13 +37,13 @@ namespace SafeExamBrowser.Client.Operations
private INotificationInfo logInfo;
private INotificationController logController;
private IPowerSupply powerSupply;
// TODO private ISystemComponent<ISystemWirelessNetworkControl> wirelessNetwork;
private ISystemInfo systemInfo;
private ITaskbar taskbar;
private TaskbarSettings taskbarSettings;
private ITerminationActivator terminationActivator;
private IText text;
private IUserInterfaceFactory uiFactory;
private IWirelessAdapter wirelessAdapter;
public event ActionRequiredEventHandler ActionRequired { add { } remove { } }
public event StatusChangedEventHandler StatusChanged;
@ -59,13 +60,13 @@ namespace SafeExamBrowser.Client.Operations
INotificationInfo logInfo,
INotificationController logController,
IPowerSupply powerSupply,
// TODO ISystemComponent<ISystemWirelessNetworkControl> wirelessNetwork,
ISystemInfo systemInfo,
ITaskbar taskbar,
TaskbarSettings taskbarSettings,
ITerminationActivator terminationActivator,
IText text,
IUserInterfaceFactory uiFactory)
IUserInterfaceFactory uiFactory,
IWirelessAdapter wirelessAdapter)
{
this.aboutInfo = aboutInfo;
this.aboutController = aboutController;
@ -84,7 +85,7 @@ namespace SafeExamBrowser.Client.Operations
this.text = text;
this.taskbar = taskbar;
this.uiFactory = uiFactory;
// TODO this.wirelessNetwork = wirelessNetwork;
this.wirelessAdapter = wirelessAdapter;
}
public OperationResult Perform()
@ -173,8 +174,7 @@ namespace SafeExamBrowser.Client.Operations
audio.Initialize();
keyboard.Initialize();
powerSupply.Initialize();
// TODO
//wirelessNetwork.Initialize();
wirelessAdapter.Initialize();
}
private void InitializeAboutNotificationForActionCenter()
@ -283,10 +283,7 @@ namespace SafeExamBrowser.Client.Operations
{
if (actionCenterSettings.ShowWirelessNetwork)
{
var control = uiFactory.CreateWirelessNetworkControl(Location.ActionCenter);
// TODO wirelessNetwork.Register(control);
actionCenter.AddSystemControl(control);
actionCenter.AddSystemControl(uiFactory.CreateWirelessNetworkControl(wirelessAdapter, Location.ActionCenter));
}
}
@ -294,10 +291,7 @@ namespace SafeExamBrowser.Client.Operations
{
if (taskbarSettings.ShowWirelessNetwork)
{
var control = uiFactory.CreateWirelessNetworkControl(Location.Taskbar);
// TODO wirelessNetwork.Register(control);
taskbar.AddSystemControl(control);
taskbar.AddSystemControl(uiFactory.CreateWirelessNetworkControl(wirelessAdapter, Location.Taskbar));
}
}
@ -325,8 +319,7 @@ namespace SafeExamBrowser.Client.Operations
audio.Terminate();
keyboard.Terminate();
powerSupply.Terminate();
// TODO
//wirelessNetwork.Terminate();
wirelessAdapter.Terminate();
}
}
}

View file

@ -119,6 +119,7 @@ namespace SafeExamBrowser.I18n.Contracts
SystemControl_BatteryRemainingCharge,
SystemControl_KeyboardLayoutTooltip,
SystemControl_WirelessConnected,
SystemControl_WirelessConnecting,
SystemControl_WirelessDisconnected,
SystemControl_WirelessNotAvailable,
Version

View file

@ -315,6 +315,9 @@
<Entry key="SystemControl_WirelessConnected">
Connected to "%%NAME%%"
</Entry>
<Entry key="SystemControl_WirelessConnecting">
Connecting...
</Entry>
<Entry key="SystemControl_WirelessDisconnected">
Disconnected
</Entry>

View file

@ -11,5 +11,5 @@ namespace SafeExamBrowser.SystemComponents.Contracts.Audio.Events
/// <summary>
/// Indicates that the volume of the system audio component has changed.
/// </summary>
public delegate void AudioVolumeChangedEventHandler(double volume, bool muted);
public delegate void VolumeChangedEventHandler(double volume, bool muted);
}

View file

@ -43,7 +43,7 @@ namespace SafeExamBrowser.SystemComponents.Contracts.Audio
/// <summary>
/// Fired when the volume of the audio device has changed.
/// </summary>
event AudioVolumeChangedEventHandler VolumeChanged;
event VolumeChangedEventHandler VolumeChanged;
/// <summary>
/// Mutes the currently active audio device.

View file

@ -11,5 +11,5 @@ namespace SafeExamBrowser.SystemComponents.Contracts.Keyboard.Events
/// <summary>
/// Indicates that the active keyboard layout has changed.
/// </summary>
public delegate void KeyboardLayoutChangedEventHandler(IKeyboardLayout layout);
public delegate void LayoutChangedEventHandler(IKeyboardLayout layout);
}

View file

@ -20,7 +20,7 @@ namespace SafeExamBrowser.SystemComponents.Contracts.Keyboard
/// <summary>
/// Fired when the active keyboard layout changed.
/// </summary>
event KeyboardLayoutChangedEventHandler LayoutChanged;
event LayoutChangedEventHandler LayoutChanged;
/// <summary>
/// Activates the keyboard layout with the given identifier.

View file

@ -11,5 +11,5 @@ namespace SafeExamBrowser.SystemComponents.Contracts.PowerSupply.Events
/// <summary>
/// Indicates that the status of the power supply for the system has changed.
/// </summary>
public delegate void PowerSupplyStatusChangedEventHandler(IPowerSupplyStatus status);
public delegate void StatusChangedEventHandler(IPowerSupplyStatus status);
}

View file

@ -18,7 +18,7 @@ namespace SafeExamBrowser.SystemComponents.Contracts.PowerSupply
/// <summary>
/// Fired when the status of the power supply changed.
/// </summary>
event PowerSupplyStatusChangedEventHandler StatusChanged;
event StatusChangedEventHandler StatusChanged;
/// <summary>
/// Retrieves the current status of the power supply.

View file

@ -53,22 +53,25 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="Audio\Events\AudioVolumeChangedEventHandler.cs" />
<Compile Include="Audio\Events\VolumeChangedEventHandler.cs" />
<Compile Include="Audio\IAudio.cs" />
<Compile Include="PowerSupply\Events\PowerSupplyStatusChangedEventHandler.cs" />
<Compile Include="PowerSupply\Events\StatusChangedEventHandler.cs" />
<Compile Include="PowerSupply\IPowerSupply.cs" />
<Compile Include="PowerSupply\BatteryChargeStatus.cs" />
<Compile Include="Keyboard\Events\KeyboardLayoutChangedEventHandler.cs" />
<Compile Include="Keyboard\Events\LayoutChangedEventHandler.cs" />
<Compile Include="Keyboard\IKeyboard.cs" />
<Compile Include="Keyboard\IKeyboardLayout.cs" />
<Compile Include="ISystemComponent.cs" />
<Compile Include="ISystemInfo.cs" />
<Compile Include="IUserInfo.cs" />
<Compile Include="IWirelessNetwork.cs" />
<Compile Include="WirelessNetwork\Events\NetworksChangedEventHandler.cs" />
<Compile Include="WirelessNetwork\Events\StatusChangedEventHandler.cs" />
<Compile Include="WirelessNetwork\IWirelessAdapter.cs" />
<Compile Include="WirelessNetwork\IWirelessNetwork.cs" />
<Compile Include="OperatingSystem.cs" />
<Compile Include="PowerSupply\IPowerSupplyStatus.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WirelessNetworkStatus.cs" />
<Compile Include="WirelessNetwork\WirelessNetworkStatus.cs" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View file

@ -6,15 +6,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
namespace SafeExamBrowser.SystemComponents.Contracts
namespace SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork.Events
{
/// <summary>
/// Defines all possible network statuses which can be determined by the application.
/// Indicates that the available wireless networks have changed.
/// </summary>
public enum WirelessNetworkStatus
{
Undefined = 0,
Connected,
Disconnected
}
public delegate void NetworksChangedEventHandler();
}

View file

@ -0,0 +1,15 @@
/*
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
*
* 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/.
*/
namespace SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork.Events
{
/// <summary>
/// Indicates that the wireless network status has changed.
/// </summary>
public delegate void StatusChangedEventHandler(WirelessNetworkStatus status);
}

View file

@ -0,0 +1,42 @@
/*
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
*
* 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 System.Collections.Generic;
using SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork.Events;
namespace SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork
{
public interface IWirelessAdapter : ISystemComponent
{
/// <summary>
/// Fired when the available wireless networks changed.
/// </summary>
event NetworksChangedEventHandler NetworksChanged;
/// <summary>
/// Fired when the wireless network status changed.
/// </summary>
event StatusChangedEventHandler StatusChanged;
/// <summary>
/// Indicates whether the system has an active wireless network adapter.
/// </summary>
bool IsAvailable { get; }
/// <summary>
/// Attempts to connect to the wireless network with the given ID.
/// </summary>
void Connect(Guid id);
/// <summary>
/// Retrieves all currently available networks.
/// </summary>
IEnumerable<IWirelessNetwork> GetNetworks();
}
}

View file

@ -8,7 +8,7 @@
using System;
namespace SafeExamBrowser.SystemComponents.Contracts
namespace SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork
{
/// <summary>
/// Defines a wireless network which can be connected to by the application.
@ -26,7 +26,7 @@ namespace SafeExamBrowser.SystemComponents.Contracts
string Name { get; }
/// <summary>
/// The signal strength of this network, as percentage.
/// The signal strength of this network, from <c>0</c> (worst) to <c>100</c> (best).
/// </summary>
int SignalStrength { get; }

View file

@ -0,0 +1,33 @@
/*
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
*
* 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/.
*/
namespace SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork
{
/// <summary>
/// Defines all possible wireless network statuses which can be determined by the application.
/// </summary>
public enum WirelessNetworkStatus
{
Undefined = 0,
/// <summary>
/// A connection has been established.
/// </summary>
Connected,
/// <summary>
/// A connection is being established.
/// </summary>
Connecting,
/// <summary>
/// No connection is established.
/// </summary>
Disconnected
}
}

View file

@ -31,7 +31,7 @@ namespace SafeExamBrowser.SystemComponents.Audio
public bool OutputMuted => audioDevice?.AudioEndpointVolume.Mute == true;
public double OutputVolume => audioDevice?.AudioEndpointVolume.MasterVolumeLevelScalar ?? 0;
public event AudioVolumeChangedEventHandler VolumeChanged;
public event VolumeChangedEventHandler VolumeChanged;
public Audio(AudioSettings settings, ILogger logger)
{

View file

@ -23,7 +23,7 @@ namespace SafeExamBrowser.SystemComponents.Keyboard
private ILogger logger;
private CultureInfo originalLanguage;
public event KeyboardLayoutChangedEventHandler LayoutChanged;
public event LayoutChangedEventHandler LayoutChanged;
public Keyboard(ILogger logger)
{

View file

@ -22,7 +22,7 @@ namespace SafeExamBrowser.SystemComponents.PowerSupply
private ILogger logger;
private Timer timer;
public event PowerSupplyStatusChangedEventHandler StatusChanged;
public event StatusChangedEventHandler StatusChanged;
public PowerSupply(ILogger logger)
{

View file

@ -70,8 +70,8 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SystemInfo.cs" />
<Compile Include="UserInfo.cs" />
<Compile Include="WirelessNetwork.cs" />
<Compile Include="WirelessNetworkDefinition.cs" />
<Compile Include="WirelessNetwork\WirelessAdapter.cs" />
<Compile Include="WirelessNetwork\WirelessNetwork.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />

View file

@ -1,263 +0,0 @@
/*
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
*
* 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 System.Collections.Generic;
using System.Linq;
using System.Timers;
using SafeExamBrowser.I18n.Contracts;
using SafeExamBrowser.Logging.Contracts;
using SafeExamBrowser.SystemComponents.Contracts;
using SimpleWifi;
using SimpleWifi.Win32;
using SimpleWifi.Win32.Interop;
namespace SafeExamBrowser.SystemComponents
{
public class WirelessNetwork // TODO: ISystemComponent<ISystemWirelessNetworkControl>
{
private readonly object @lock = new object();
// TODOprivate List<ISystemWirelessNetworkControl> controls;
private List<WirelessNetworkDefinition> networks;
private bool hasWifiAdapter;
private ILogger logger;
private IText text;
private Timer timer;
private Wifi wifi;
public WirelessNetwork(ILogger logger, IText text)
{
// TODOthis.controls = new List<ISystemWirelessNetworkControl>();
this.logger = logger;
this.networks = new List<WirelessNetworkDefinition>();
this.text = text;
}
public void Initialize()
{
wifi = new Wifi();
wifi.ConnectionStatusChanged += Wifi_ConnectionStatusChanged;
hasWifiAdapter = !wifi.NoWifiAvailable && !IsTurnedOff();
if (hasWifiAdapter)
{
UpdateAvailableNetworks();
StartTimer();
logger.Info("Started monitoring the wireless network adapter.");
}
else
{
logger.Info("Wireless networks cannot be monitored, as there is no hardware adapter available or it is turned off.");
}
}
// TODO
//public void Register(ISystemWirelessNetworkControl control)
//{
// if (hasWifiAdapter)
// {
// control.HasWirelessNetworkAdapter = true;
// control.NetworkSelected += Control_NetworkSelected;
// }
// else
// {
// control.HasWirelessNetworkAdapter = false;
// control.SetInformation(text.Get(TextKey.SystemControl_WirelessNotAvailable));
// }
// lock (@lock)
// {
// controls.Add(control);
// }
// if (hasWifiAdapter)
// {
// UpdateControls();
// }
//}
public void Terminate()
{
if (timer != null)
{
timer.Stop();
logger.Info("Stopped monitoring the wireless network adapter.");
}
// TODO
//foreach (var control in controls)
//{
// control.Close();
//}
}
private void Control_NetworkSelected(Guid id)
{
lock (@lock)
{
var network = networks.First(n => n.Id == id);
try
{
var request = new AuthRequest(network.AccessPoint);
logger.Info($"Attempting to connect to '{network.Name}'...");
network.AccessPoint.ConnectAsync(request, false, (success) => AccessPoint_OnConnectComplete(network.Name, success));
// TODO
//foreach (var control in controls)
//{
// control.IsConnecting = true;
//}
}
catch (Exception e)
{
logger.Error($"Failed to connect to wireless network '{network.Name}!'", e);
}
}
}
private void AccessPoint_OnConnectComplete(string name, bool success)
{
if (success)
{
logger.Info($"Successfully connected to wireless network '{name}'.");
}
else
{
logger.Error($"Failed to connect to wireless network '{name}!'");
}
lock (@lock)
{
// TODO
//foreach (var control in controls)
//{
// control.IsConnecting = false;
//}
}
UpdateAvailableNetworks();
UpdateControls();
}
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
{
UpdateAvailableNetworks();
UpdateControls();
}
private void Wifi_ConnectionStatusChanged(object sender, WifiStatusEventArgs e)
{
UpdateAvailableNetworks();
UpdateControls();
}
private bool IsTurnedOff()
{
try
{
var client = new WlanClient();
foreach (var @interface in client.Interfaces)
{
foreach (var state in @interface.RadioState.PhyRadioState)
{
if (state.dot11SoftwareRadioState == Dot11RadioState.On && state.dot11HardwareRadioState == Dot11RadioState.On)
{
return false;
}
}
}
}
catch (Exception e)
{
logger.Error("Failed to determine the radio state of the wireless adapter(s)! Assuming it is (all are) turned off...", e);
}
return true;
}
private void UpdateControls()
{
lock (@lock)
{
try
{
var currentNetwork = networks.FirstOrDefault(n => n.Status == WirelessNetworkStatus.Connected);
// TODO
//foreach (var control in controls)
//{
// if (wifi.ConnectionStatus == WifiStatus.Disconnected)
// {
// control.SetInformation(text.Get(TextKey.SystemControl_WirelessDisconnected));
// }
// if (currentNetwork != null)
// {
// control.SetInformation(text.Get(TextKey.SystemControl_WirelessConnected).Replace("%%NAME%%", currentNetwork.Name));
// }
// control.NetworkStatus = ToStatus(wifi.ConnectionStatus);
// control.Update(networks.ToList());
//}
}
catch (Exception e)
{
logger.Error("Failed to update the wireless network adapter status!", e);
}
}
}
private void UpdateAvailableNetworks()
{
lock (@lock)
{
networks.Clear();
foreach (var accessPoint in wifi.GetAccessPoints())
{
// The user may only connect to an already configured wireless network!
if (accessPoint.HasProfile)
{
networks.Add(ToDefinition(accessPoint));
}
}
}
}
private void StartTimer()
{
const int FIVE_SECONDS = 5000;
timer = new Timer(FIVE_SECONDS);
timer.Elapsed += Timer_Elapsed;
timer.AutoReset = true;
timer.Start();
}
private WirelessNetworkDefinition ToDefinition(AccessPoint accessPoint)
{
return new WirelessNetworkDefinition
{
AccessPoint = accessPoint,
Name = accessPoint.Name,
SignalStrength = Convert.ToInt32(accessPoint.SignalStrength),
Status = accessPoint.IsConnected ? WirelessNetworkStatus.Connected : WirelessNetworkStatus.Disconnected
};
}
private WirelessNetworkStatus ToStatus(WifiStatus status)
{
return status == WifiStatus.Connected ? WirelessNetworkStatus.Connected : WirelessNetworkStatus.Disconnected;
}
}
}

View file

@ -0,0 +1,206 @@
/*
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
*
* 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 System.Collections.Generic;
using System.Linq;
using System.Timers;
using SafeExamBrowser.I18n.Contracts;
using SafeExamBrowser.Logging.Contracts;
using SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork;
using SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork.Events;
using SimpleWifi;
using SimpleWifi.Win32;
using SimpleWifi.Win32.Interop;
namespace SafeExamBrowser.SystemComponents.WirelessNetwork
{
public class WirelessAdapter : IWirelessAdapter
{
private readonly object @lock = new object();
private List<WirelessNetwork> networks;
private ILogger logger;
private IText text;
private Timer timer;
private Wifi wifi;
public bool IsAvailable { get; private set; }
public event NetworksChangedEventHandler NetworksChanged;
public event StatusChangedEventHandler StatusChanged;
public WirelessAdapter(ILogger logger, IText text)
{
this.logger = logger;
this.networks = new List<WirelessNetwork>();
this.text = text;
}
public void Connect(Guid id)
{
lock (@lock)
{
var network = networks.FirstOrDefault(n => n.Id == id);
if (network != default(WirelessNetwork))
{
try
{
var request = new AuthRequest(network.AccessPoint);
logger.Info($"Attempting to connect to '{network.Name}'...");
network.AccessPoint.ConnectAsync(request, false, (success) => AccessPoint_OnConnectCompleted(network.Name, success));
StatusChanged?.Invoke(WirelessNetworkStatus.Connecting);
}
catch (Exception e)
{
logger.Error($"Failed to connect to wireless network '{network.Name}!'", e);
}
}
else
{
logger.Warn($"Could not find network with id '{id}'!");
}
}
}
public IEnumerable<IWirelessNetwork> GetNetworks()
{
lock (@lock)
{
return new List<WirelessNetwork>(networks);
}
}
public void Initialize()
{
const int FIVE_SECONDS = 5000;
wifi = new Wifi();
wifi.ConnectionStatusChanged += Wifi_ConnectionStatusChanged;
IsAvailable = !wifi.NoWifiAvailable && !IsTurnedOff();
if (IsAvailable)
{
UpdateAvailableNetworks();
timer = new Timer(FIVE_SECONDS);
timer.Elapsed += Timer_Elapsed;
timer.AutoReset = true;
timer.Start();
logger.Info("Started monitoring the wireless network adapter.");
}
else
{
logger.Info("Wireless networks cannot be monitored, as there is no hardware adapter available or it is turned off.");
}
}
public void Terminate()
{
if (timer != null)
{
timer.Stop();
logger.Info("Stopped monitoring the wireless network adapter.");
}
}
private void AccessPoint_OnConnectCompleted(string name, bool success)
{
if (success)
{
logger.Info($"Successfully connected to wireless network '{name}'.");
}
else
{
logger.Error($"Failed to connect to wireless network '{name}!'");
}
UpdateAvailableNetworks();
}
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
{
UpdateAvailableNetworks();
}
private void Wifi_ConnectionStatusChanged(object sender, WifiStatusEventArgs e)
{
UpdateAvailableNetworks();
}
private bool IsTurnedOff()
{
try
{
var client = new WlanClient();
foreach (var @interface in client.Interfaces)
{
foreach (var state in @interface.RadioState.PhyRadioState)
{
if (state.dot11SoftwareRadioState == Dot11RadioState.On && state.dot11HardwareRadioState == Dot11RadioState.On)
{
return false;
}
}
}
}
catch (Exception e)
{
logger.Error("Failed to determine the radio state of the wireless adapter(s)! Assuming it is (all are) turned off...", e);
}
return true;
}
private void UpdateAvailableNetworks()
{
lock (@lock)
{
try
{
networks.Clear();
foreach (var accessPoint in wifi.GetAccessPoints())
{
// The user may only connect to an already configured wireless network!
if (accessPoint.HasProfile)
{
networks.Add(ToNetwork(accessPoint));
}
}
NetworksChanged?.Invoke();
}
catch (Exception e)
{
logger.Error("Failed to update available networks!", e);
}
}
}
private WirelessNetwork ToNetwork(AccessPoint accessPoint)
{
return new WirelessNetwork
{
AccessPoint = accessPoint,
Name = accessPoint.Name,
SignalStrength = Convert.ToInt32(accessPoint.SignalStrength),
Status = accessPoint.IsConnected ? WirelessNetworkStatus.Connected : WirelessNetworkStatus.Disconnected
};
}
private WirelessNetworkStatus ToStatus(WifiStatus status)
{
return status == WifiStatus.Connected ? WirelessNetworkStatus.Connected : WirelessNetworkStatus.Disconnected;
}
}
}

View file

@ -7,12 +7,12 @@
*/
using System;
using SafeExamBrowser.SystemComponents.Contracts;
using SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork;
using SimpleWifi;
namespace SafeExamBrowser.SystemComponents
namespace SafeExamBrowser.SystemComponents.WirelessNetwork
{
internal class WirelessNetworkDefinition : IWirelessNetwork
internal class WirelessNetwork : IWirelessNetwork
{
internal AccessPoint AccessPoint { get; set; }
@ -21,7 +21,7 @@ namespace SafeExamBrowser.SystemComponents
public int SignalStrength { get; set; }
public WirelessNetworkStatus Status { get; set; }
public WirelessNetworkDefinition()
public WirelessNetwork()
{
Id = Guid.NewGuid();
}

View file

@ -15,6 +15,7 @@ using SafeExamBrowser.Logging.Contracts;
using SafeExamBrowser.SystemComponents.Contracts.Audio;
using SafeExamBrowser.SystemComponents.Contracts.Keyboard;
using SafeExamBrowser.SystemComponents.Contracts.PowerSupply;
using SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork;
using SafeExamBrowser.UserInterface.Contracts.Browser;
using SafeExamBrowser.UserInterface.Contracts.Shell;
using SafeExamBrowser.UserInterface.Contracts.Windows;
@ -90,6 +91,6 @@ namespace SafeExamBrowser.UserInterface.Contracts
/// <summary>
/// Creates a system control which allows to change the wireless network connection of the computer.
/// </summary>
ISystemWirelessNetworkControl CreateWirelessNetworkControl(Location location);
ISystemControl CreateWirelessNetworkControl(IWirelessAdapter wirelessAdapter, Location location);
}
}

View file

@ -75,7 +75,6 @@
<Compile Include="Shell\IApplicationControl.cs" />
<Compile Include="Shell\INotificationControl.cs" />
<Compile Include="Shell\ISystemControl.cs" />
<Compile Include="Shell\ISystemWirelessNetworkControl.cs" />
<Compile Include="Shell\ITaskbar.cs" />
<Compile Include="Shell\Location.cs" />
<Compile Include="Windows\Events\WindowClosingEventHandler.cs" />

View file

@ -1,45 +0,0 @@
/*
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
*
* 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.UserInterface.Contracts.Shell.Events;
namespace SafeExamBrowser.UserInterface.Contracts.Shell
{
/// <summary>
/// The control of the wireless network system component.
/// </summary>
public interface ISystemWirelessNetworkControl : ISystemControl
{
/// <summary>
/// Defines whether the computer has a wireless network adapter.
/// </summary>
bool HasWirelessNetworkAdapter { set; }
/// <summary>
/// Indicates to the user that a wireless network connection is being established.
/// </summary>
bool IsConnecting { set; }
// TODO
///// <summary>
///// Sets the current wireless network status.
///// </summary>
//WirelessNetworkStatus NetworkStatus { set; }
/// <summary>
/// Event fired when the user selected a wireless network.
/// </summary>
event WirelessNetworkSelectedEventHandler NetworkSelected;
// TODO
///// <summary>
///// Updates the list of available networks.
///// </summary>
//void Update(IEnumerable<IWirelessNetwork> networks);
}
}

View file

@ -34,10 +34,10 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls
this.layout = layout;
InitializeComponent();
InitializeEvents();
InitializeLayoutButton();
}
private void InitializeEvents()
private void InitializeLayoutButton()
{
Button.Click += (o, args) => LayoutSelected?.Invoke(this, EventArgs.Empty);
CultureCodeTextBlock.Text = layout.CultureCode;

View file

@ -6,10 +6,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
using System.Windows;
using System.Windows.Controls;
using SafeExamBrowser.SystemComponents.Contracts;
using SafeExamBrowser.UserInterface.Contracts.Shell.Events;
using SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork;
namespace SafeExamBrowser.UserInterface.Desktop.Controls
{
@ -17,34 +17,22 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls
{
private IWirelessNetwork network;
public bool IsCurrent
{
set { IsCurrentTextBlock.Visibility = value ? Visibility.Visible : Visibility.Hidden; }
}
public string NetworkName
{
set { NetworkNameTextBlock.Text = value; }
}
public int SignalStrength
{
set { SignalStrengthTextBlock.Text = $"{value}%"; }
}
public event WirelessNetworkSelectedEventHandler NetworkSelected;
public event EventHandler NetworkSelected;
public ActionCenterWirelessNetworkButton(IWirelessNetwork network)
{
this.network = network;
InitializeComponent();
InitializeEvents();
InitializeNetworkButton();
}
private void InitializeEvents()
private void InitializeNetworkButton()
{
Button.Click += (o, args) => NetworkSelected?.Invoke(network.Id);
Button.Click += (o, args) => NetworkSelected?.Invoke(this, EventArgs.Empty);
IsCurrentTextBlock.Visibility = network.Status == WirelessNetworkStatus.Connected ? Visibility.Visible : Visibility.Hidden;
NetworkNameTextBlock.Text = network.Name;
SignalStrengthTextBlock.Text = $"{network.SignalStrength}%";
}
}
}

View file

@ -7,112 +7,35 @@
*/
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using FontAwesome.WPF;
using SafeExamBrowser.SystemComponents.Contracts;
using SafeExamBrowser.I18n.Contracts;
using SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork;
using SafeExamBrowser.UserInterface.Contracts.Shell;
using SafeExamBrowser.UserInterface.Contracts.Shell.Events;
using SafeExamBrowser.UserInterface.Shared.Utilities;
namespace SafeExamBrowser.UserInterface.Desktop.Controls
{
public partial class ActionCenterWirelessNetworkControl : UserControl, ISystemWirelessNetworkControl
public partial class ActionCenterWirelessNetworkControl : UserControl, ISystemControl
{
public bool HasWirelessNetworkAdapter
private IWirelessAdapter wirelessAdapter;
private IText text;
public ActionCenterWirelessNetworkControl(IWirelessAdapter wirelessAdapter, IText text)
{
set
{
Dispatcher.Invoke(() =>
{
Button.IsEnabled = value;
NoAdapterIcon.Visibility = value ? Visibility.Collapsed : Visibility.Visible;
});
}
}
this.wirelessAdapter = wirelessAdapter;
this.text = text;
public bool IsConnecting
{
set
{
Dispatcher.Invoke(() =>
{
LoadingIcon.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
SignalStrengthIcon.Visibility = value ? Visibility.Collapsed : Visibility.Visible;
NetworkStatusIcon.Visibility = value ? Visibility.Collapsed : Visibility.Visible;
});
}
}
public WirelessNetworkStatus NetworkStatus
{
set
{
Dispatcher.Invoke(() =>
{
var icon = value == WirelessNetworkStatus.Connected ? FontAwesomeIcon.Check : FontAwesomeIcon.Close;
var brush = value == WirelessNetworkStatus.Connected ? Brushes.Green : Brushes.Orange;
if (value == WirelessNetworkStatus.Disconnected)
{
SignalStrengthIcon.Child = GetIcon(0);
}
NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(icon, brush);
});
}
}
public event WirelessNetworkSelectedEventHandler NetworkSelected;
public ActionCenterWirelessNetworkControl()
{
InitializeComponent();
InitializeWirelessNetworkControl();
}
public void Close()
{
Dispatcher.Invoke(() => Popup.IsOpen = false);
}
public void SetInformation(string text)
{
Dispatcher.Invoke(() =>
{
Button.ToolTip = text;
Text.Text = text;
});
}
public void Update(IEnumerable<IWirelessNetwork> networks)
{
Dispatcher.Invoke(() =>
{
NetworksStackPanel.Children.Clear();
foreach (var network in networks)
{
var button = new ActionCenterWirelessNetworkButton(network);
var isCurrent = network.Status == WirelessNetworkStatus.Connected;
button.IsCurrent = isCurrent;
button.NetworkName = network.Name;
button.SignalStrength = network.SignalStrength;
button.NetworkSelected += (id) => NetworkSelected?.Invoke(id);
if (isCurrent)
{
NetworkStatus = network.Status;
SignalStrengthIcon.Child = GetIcon(network.SignalStrength);
}
NetworksStackPanel.Children.Add(button);
}
});
Dispatcher.InvokeAsync(() => Popup.IsOpen = false);
}
private void InitializeWirelessNetworkControl()
@ -125,6 +48,85 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls
Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver));
Popup.Opened += (o, args) => Grid.Background = Brushes.Gray;
Popup.Closed += (o, args) => Grid.Background = originalBrush;
if (wirelessAdapter.IsAvailable)
{
wirelessAdapter.NetworksChanged += WirelessAdapter_NetworksChanged;
wirelessAdapter.StatusChanged += WirelessAdapter_StatusChanged;
UpdateNetworks();
}
else
{
Button.IsEnabled = false;
NoAdapterIcon.Visibility = Visibility.Visible;
UpdateText(text.Get(TextKey.SystemControl_WirelessNotAvailable));
}
}
private void WirelessAdapter_NetworksChanged()
{
Dispatcher.InvokeAsync(UpdateNetworks);
}
private void WirelessAdapter_StatusChanged(WirelessNetworkStatus status)
{
Dispatcher.InvokeAsync(() => UpdateStatus(status));
}
private void UpdateNetworks()
{
var status = WirelessNetworkStatus.Disconnected;
NetworksStackPanel.Children.Clear();
foreach (var network in wirelessAdapter.GetNetworks())
{
var button = new ActionCenterWirelessNetworkButton(network);
button.NetworkSelected += (o, args) => wirelessAdapter.Connect(network.Id);
if (network.Status == WirelessNetworkStatus.Connected)
{
status = WirelessNetworkStatus.Connected;
SignalStrengthIcon.Child = GetIcon(network.SignalStrength);
UpdateText(text.Get(TextKey.SystemControl_WirelessConnected).Replace("%%NAME%%", network.Name));
}
NetworksStackPanel.Children.Add(button);
}
UpdateStatus(status);
}
private void UpdateStatus(WirelessNetworkStatus status)
{
LoadingIcon.Visibility = Visibility.Collapsed;
SignalStrengthIcon.Visibility = Visibility.Visible;
NetworkStatusIcon.Visibility = Visibility.Visible;
switch (status)
{
case WirelessNetworkStatus.Connected:
NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Check, Brushes.Green);
break;
case WirelessNetworkStatus.Connecting:
LoadingIcon.Visibility = Visibility.Visible;
SignalStrengthIcon.Visibility = Visibility.Collapsed;
NetworkStatusIcon.Visibility = Visibility.Collapsed;
UpdateText(text.Get(TextKey.SystemControl_WirelessConnecting));
break;
default:
NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Close, Brushes.Orange);
SignalStrengthIcon.Child = GetIcon(0);
UpdateText(text.Get(TextKey.SystemControl_WirelessDisconnected));
break;
}
}
private void UpdateText(string text)
{
Button.ToolTip = text;
Text.Text = text;
}
private UIElement GetIcon(int signalStrength)

View file

@ -6,45 +6,33 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
using System.Windows;
using System.Windows.Controls;
using SafeExamBrowser.SystemComponents.Contracts;
using SafeExamBrowser.UserInterface.Contracts.Shell.Events;
using SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork;
namespace SafeExamBrowser.UserInterface.Desktop.Controls
{
public partial class TaskbarWirelessNetworkButton : UserControl
{
private readonly IWirelessNetwork network;
private IWirelessNetwork network;
public bool IsCurrent
{
set { IsCurrentTextBlock.Visibility = value ? Visibility.Visible : Visibility.Hidden; }
}
public string NetworkName
{
set { NetworkNameTextBlock.Text = value; }
}
public int SignalStrength
{
set { SignalStrengthTextBlock.Text = $"{value}%"; }
}
public event WirelessNetworkSelectedEventHandler NetworkSelected;
public event EventHandler NetworkSelected;
public TaskbarWirelessNetworkButton(IWirelessNetwork network)
{
this.network = network;
InitializeComponent();
InitializeEvents();
InitializeNetworkButton();
}
private void InitializeEvents()
private void InitializeNetworkButton()
{
Button.Click += (o, args) => NetworkSelected?.Invoke(network.Id);
Button.Click += (o, args) => NetworkSelected?.Invoke(this, EventArgs.Empty);
IsCurrentTextBlock.Visibility = network.Status == WirelessNetworkStatus.Connected ? Visibility.Visible : Visibility.Hidden;
NetworkNameTextBlock.Text = network.Name;
SignalStrengthTextBlock.Text = $"{network.SignalStrength}%";
}
}
}

View file

@ -7,108 +7,35 @@
*/
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using FontAwesome.WPF;
using SafeExamBrowser.SystemComponents.Contracts;
using SafeExamBrowser.I18n.Contracts;
using SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork;
using SafeExamBrowser.UserInterface.Contracts.Shell;
using SafeExamBrowser.UserInterface.Contracts.Shell.Events;
using SafeExamBrowser.UserInterface.Shared.Utilities;
namespace SafeExamBrowser.UserInterface.Desktop.Controls
{
public partial class TaskbarWirelessNetworkControl : UserControl, ISystemWirelessNetworkControl
public partial class TaskbarWirelessNetworkControl : UserControl, ISystemControl
{
public bool HasWirelessNetworkAdapter
private IWirelessAdapter wirelessAdapter;
private IText text;
public TaskbarWirelessNetworkControl(IWirelessAdapter wirelessAdapter, IText text)
{
set
{
Dispatcher.InvokeAsync(() =>
{
Button.IsEnabled = value;
NoAdapterIcon.Visibility = value ? Visibility.Collapsed : Visibility.Visible;
});
}
}
this.wirelessAdapter = wirelessAdapter;
this.text = text;
public bool IsConnecting
{
set
{
Dispatcher.Invoke(() =>
{
LoadingIcon.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
SignalStrengthIcon.Visibility = value ? Visibility.Collapsed : Visibility.Visible;
NetworkStatusIcon.Visibility = value ? Visibility.Collapsed : Visibility.Visible;
});
}
}
public WirelessNetworkStatus NetworkStatus
{
set
{
Dispatcher.InvokeAsync(() =>
{
var icon = value == WirelessNetworkStatus.Connected ? FontAwesomeIcon.Check : FontAwesomeIcon.Close;
var brush = value == WirelessNetworkStatus.Connected ? Brushes.Green : Brushes.Orange;
if (value == WirelessNetworkStatus.Disconnected)
{
SignalStrengthIcon.Child = GetIcon(0);
}
NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(icon, brush);
});
}
}
public event WirelessNetworkSelectedEventHandler NetworkSelected;
public TaskbarWirelessNetworkControl()
{
InitializeComponent();
InitializeWirelessNetworkControl();
}
public void Close()
{
Popup.IsOpen = false;
}
public void SetInformation(string text)
{
Dispatcher.InvokeAsync(() => Button.ToolTip = text);
}
public void Update(IEnumerable<IWirelessNetwork> networks)
{
Dispatcher.InvokeAsync(() =>
{
NetworksStackPanel.Children.Clear();
foreach (var network in networks)
{
var button = new TaskbarWirelessNetworkButton(network);
var isCurrent = network.Status == WirelessNetworkStatus.Connected;
button.IsCurrent = isCurrent;
button.NetworkName = network.Name;
button.SignalStrength = network.SignalStrength;
button.NetworkSelected += (id) => NetworkSelected?.Invoke(id);
if (isCurrent)
{
NetworkStatus = network.Status;
SignalStrengthIcon.Child = GetIcon(network.SignalStrength);
}
NetworksStackPanel.Children.Add(button);
}
});
Dispatcher.InvokeAsync(() => Popup.IsOpen = false);
}
private void InitializeWirelessNetworkControl()
@ -131,6 +58,84 @@ namespace SafeExamBrowser.UserInterface.Desktop.Controls
Background = originalBrush;
Button.Background = originalBrush;
};
if (wirelessAdapter.IsAvailable)
{
wirelessAdapter.NetworksChanged += WirelessAdapter_NetworksChanged;
wirelessAdapter.StatusChanged += WirelessAdapter_StatusChanged;
UpdateNetworks();
}
else
{
Button.IsEnabled = false;
NoAdapterIcon.Visibility = Visibility.Visible;
UpdateText(text.Get(TextKey.SystemControl_WirelessNotAvailable));
}
}
private void WirelessAdapter_NetworksChanged()
{
Dispatcher.InvokeAsync(UpdateNetworks);
}
private void WirelessAdapter_StatusChanged(WirelessNetworkStatus status)
{
Dispatcher.InvokeAsync(() => UpdateStatus(status));
}
private void UpdateNetworks()
{
var status = WirelessNetworkStatus.Disconnected;
NetworksStackPanel.Children.Clear();
foreach (var network in wirelessAdapter.GetNetworks())
{
var button = new TaskbarWirelessNetworkButton(network);
button.NetworkSelected += (o, args) => wirelessAdapter.Connect(network.Id);
if (network.Status == WirelessNetworkStatus.Connected)
{
status = WirelessNetworkStatus.Connected;
SignalStrengthIcon.Child = GetIcon(network.SignalStrength);
UpdateText(text.Get(TextKey.SystemControl_WirelessConnected).Replace("%%NAME%%", network.Name));
}
NetworksStackPanel.Children.Add(button);
}
UpdateStatus(status);
}
private void UpdateStatus(WirelessNetworkStatus status)
{
LoadingIcon.Visibility = Visibility.Collapsed;
SignalStrengthIcon.Visibility = Visibility.Visible;
NetworkStatusIcon.Visibility = Visibility.Visible;
switch (status)
{
case WirelessNetworkStatus.Connected:
NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Check, Brushes.Green);
break;
case WirelessNetworkStatus.Connecting:
LoadingIcon.Visibility = Visibility.Visible;
SignalStrengthIcon.Visibility = Visibility.Collapsed;
NetworkStatusIcon.Visibility = Visibility.Collapsed;
UpdateText(text.Get(TextKey.SystemControl_WirelessConnecting));
break;
default:
NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Close, Brushes.Orange);
SignalStrengthIcon.Child = GetIcon(0);
UpdateText(text.Get(TextKey.SystemControl_WirelessDisconnected));
break;
}
}
private void UpdateText(string text)
{
Button.ToolTip = text;
}
private UIElement GetIcon(int signalStrength)

View file

@ -19,6 +19,7 @@ using SafeExamBrowser.Logging.Contracts;
using SafeExamBrowser.SystemComponents.Contracts.Audio;
using SafeExamBrowser.SystemComponents.Contracts.Keyboard;
using SafeExamBrowser.SystemComponents.Contracts.PowerSupply;
using SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork;
using SafeExamBrowser.UserInterface.Contracts;
using SafeExamBrowser.UserInterface.Contracts.Browser;
using SafeExamBrowser.UserInterface.Contracts.Shell;
@ -172,15 +173,15 @@ namespace SafeExamBrowser.UserInterface.Desktop
return splashScreen;
}
public ISystemWirelessNetworkControl CreateWirelessNetworkControl(Location location)
public ISystemControl CreateWirelessNetworkControl(IWirelessAdapter wirelessAdapter, Location location)
{
if (location == Location.ActionCenter)
{
return new ActionCenterWirelessNetworkControl();
return new ActionCenterWirelessNetworkControl(wirelessAdapter, text);
}
else
{
return new TaskbarWirelessNetworkControl();
return new TaskbarWirelessNetworkControl(wirelessAdapter, text);
}
}

View file

@ -34,10 +34,10 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls
this.layout = layout;
InitializeComponent();
InitializeEvents();
InitializeLayoutButton();
}
private void InitializeEvents()
private void InitializeLayoutButton()
{
Button.Click += (o, args) => LayoutSelected?.Invoke(this, EventArgs.Empty);
CultureCodeTextBlock.Text = layout.CultureCode;

View file

@ -6,10 +6,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
using System.Windows;
using System.Windows.Controls;
using SafeExamBrowser.SystemComponents.Contracts;
using SafeExamBrowser.UserInterface.Contracts.Shell.Events;
using SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork;
namespace SafeExamBrowser.UserInterface.Mobile.Controls
{
@ -17,34 +17,22 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls
{
private IWirelessNetwork network;
public bool IsCurrent
{
set { IsCurrentTextBlock.Visibility = value ? Visibility.Visible : Visibility.Hidden; }
}
public string NetworkName
{
set { NetworkNameTextBlock.Text = value; }
}
public int SignalStrength
{
set { SignalStrengthTextBlock.Text = $"{value}%"; }
}
public event WirelessNetworkSelectedEventHandler NetworkSelected;
public event EventHandler NetworkSelected;
public ActionCenterWirelessNetworkButton(IWirelessNetwork network)
{
this.network = network;
InitializeComponent();
InitializeEvents();
InitializeNetworkButton();
}
private void InitializeEvents()
private void InitializeNetworkButton()
{
Button.Click += (o, args) => NetworkSelected?.Invoke(network.Id);
Button.Click += (o, args) => NetworkSelected?.Invoke(this, EventArgs.Empty);
IsCurrentTextBlock.Visibility = network.Status == WirelessNetworkStatus.Connected ? Visibility.Visible : Visibility.Hidden;
NetworkNameTextBlock.Text = network.Name;
SignalStrengthTextBlock.Text = $"{network.SignalStrength}%";
}
}
}

View file

@ -7,112 +7,35 @@
*/
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using FontAwesome.WPF;
using SafeExamBrowser.SystemComponents.Contracts;
using SafeExamBrowser.I18n.Contracts;
using SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork;
using SafeExamBrowser.UserInterface.Contracts.Shell;
using SafeExamBrowser.UserInterface.Contracts.Shell.Events;
using SafeExamBrowser.UserInterface.Shared.Utilities;
namespace SafeExamBrowser.UserInterface.Mobile.Controls
{
public partial class ActionCenterWirelessNetworkControl : UserControl, ISystemWirelessNetworkControl
public partial class ActionCenterWirelessNetworkControl : UserControl, ISystemControl
{
public bool HasWirelessNetworkAdapter
private IWirelessAdapter wirelessAdapter;
private IText text;
public ActionCenterWirelessNetworkControl(IWirelessAdapter wirelessAdapter, IText text)
{
set
{
Dispatcher.Invoke(() =>
{
Button.IsEnabled = value;
NoAdapterIcon.Visibility = value ? Visibility.Collapsed : Visibility.Visible;
});
}
}
this.wirelessAdapter = wirelessAdapter;
this.text = text;
public bool IsConnecting
{
set
{
Dispatcher.Invoke(() =>
{
LoadingIcon.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
SignalStrengthIcon.Visibility = value ? Visibility.Collapsed : Visibility.Visible;
NetworkStatusIcon.Visibility = value ? Visibility.Collapsed : Visibility.Visible;
});
}
}
public WirelessNetworkStatus NetworkStatus
{
set
{
Dispatcher.Invoke(() =>
{
var icon = value == WirelessNetworkStatus.Connected ? FontAwesomeIcon.Check : FontAwesomeIcon.Close;
var brush = value == WirelessNetworkStatus.Connected ? Brushes.Green : Brushes.Orange;
if (value == WirelessNetworkStatus.Disconnected)
{
SignalStrengthIcon.Child = GetIcon(0);
}
NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(icon, brush);
});
}
}
public event WirelessNetworkSelectedEventHandler NetworkSelected;
public ActionCenterWirelessNetworkControl()
{
InitializeComponent();
InitializeWirelessNetworkControl();
}
public void Close()
{
Dispatcher.Invoke(() => Popup.IsOpen = false);
}
public void SetInformation(string text)
{
Dispatcher.Invoke(() =>
{
Button.ToolTip = text;
Text.Text = text;
});
}
public void Update(IEnumerable<IWirelessNetwork> networks)
{
Dispatcher.Invoke(() =>
{
NetworksStackPanel.Children.Clear();
foreach (var network in networks)
{
var button = new ActionCenterWirelessNetworkButton(network);
var isCurrent = network.Status == WirelessNetworkStatus.Connected;
button.IsCurrent = isCurrent;
button.NetworkName = network.Name;
button.SignalStrength = network.SignalStrength;
button.NetworkSelected += (id) => NetworkSelected?.Invoke(id);
if (isCurrent)
{
NetworkStatus = network.Status;
SignalStrengthIcon.Child = GetIcon(network.SignalStrength);
}
NetworksStackPanel.Children.Add(button);
}
});
Dispatcher.InvokeAsync(() => Popup.IsOpen = false);
}
private void InitializeWirelessNetworkControl()
@ -125,12 +48,91 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls
Popup.MouseLeave += (o, args) => Task.Delay(250).ContinueWith(_ => Dispatcher.Invoke(() => Popup.IsOpen = IsMouseOver));
Popup.Opened += (o, args) => Grid.Background = Brushes.Gray;
Popup.Closed += (o, args) => Grid.Background = originalBrush;
if (wirelessAdapter.IsAvailable)
{
wirelessAdapter.NetworksChanged += WirelessAdapter_NetworksChanged;
wirelessAdapter.StatusChanged += WirelessAdapter_StatusChanged;
UpdateNetworks();
}
else
{
Button.IsEnabled = false;
NoAdapterIcon.Visibility = Visibility.Visible;
UpdateText(text.Get(TextKey.SystemControl_WirelessNotAvailable));
}
}
private void WirelessAdapter_NetworksChanged()
{
Dispatcher.InvokeAsync(UpdateNetworks);
}
private void WirelessAdapter_StatusChanged(WirelessNetworkStatus status)
{
Dispatcher.InvokeAsync(() => UpdateStatus(status));
}
private void UpdateNetworks()
{
var status = WirelessNetworkStatus.Disconnected;
NetworksStackPanel.Children.Clear();
foreach (var network in wirelessAdapter.GetNetworks())
{
var button = new ActionCenterWirelessNetworkButton(network);
button.NetworkSelected += (o, args) => wirelessAdapter.Connect(network.Id);
if (network.Status == WirelessNetworkStatus.Connected)
{
status = WirelessNetworkStatus.Connected;
SignalStrengthIcon.Child = GetIcon(network.SignalStrength);
UpdateText(text.Get(TextKey.SystemControl_WirelessConnected).Replace("%%NAME%%", network.Name));
}
NetworksStackPanel.Children.Add(button);
}
UpdateStatus(status);
}
private void UpdateStatus(WirelessNetworkStatus status)
{
LoadingIcon.Visibility = Visibility.Collapsed;
SignalStrengthIcon.Visibility = Visibility.Visible;
NetworkStatusIcon.Visibility = Visibility.Visible;
switch (status)
{
case WirelessNetworkStatus.Connected:
NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Check, Brushes.Green);
break;
case WirelessNetworkStatus.Connecting:
LoadingIcon.Visibility = Visibility.Visible;
SignalStrengthIcon.Visibility = Visibility.Collapsed;
NetworkStatusIcon.Visibility = Visibility.Collapsed;
UpdateText(text.Get(TextKey.SystemControl_WirelessConnecting));
break;
default:
NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Close, Brushes.Orange);
SignalStrengthIcon.Child = GetIcon(0);
UpdateText(text.Get(TextKey.SystemControl_WirelessDisconnected));
break;
}
}
private void UpdateText(string text)
{
Button.ToolTip = text;
Text.Text = text;
}
private UIElement GetIcon(int signalStrength)
{
var icon = signalStrength > 66 ? "100" : (signalStrength > 33 ? "66" : (signalStrength > 0 ? "33" : "0"));
var uri = new Uri($"pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/WiFi_Light_{icon}.xaml");
var uri = new Uri($"pack://application:,,,/SafeExamBrowser.UserInterface.Mobile;component/Images/WiFi_Light_{icon}.xaml");
var resource = new XamlIconResource(uri);
return IconResourceLoader.Load(resource);

View file

@ -6,45 +6,33 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
using System.Windows;
using System.Windows.Controls;
using SafeExamBrowser.SystemComponents.Contracts;
using SafeExamBrowser.UserInterface.Contracts.Shell.Events;
using SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork;
namespace SafeExamBrowser.UserInterface.Mobile.Controls
{
public partial class TaskbarWirelessNetworkButton : UserControl
{
private readonly IWirelessNetwork network;
private IWirelessNetwork network;
public bool IsCurrent
{
set { IsCurrentTextBlock.Visibility = value ? Visibility.Visible : Visibility.Hidden; }
}
public string NetworkName
{
set { NetworkNameTextBlock.Text = value; }
}
public int SignalStrength
{
set { SignalStrengthTextBlock.Text = $"{value}%"; }
}
public event WirelessNetworkSelectedEventHandler NetworkSelected;
public event EventHandler NetworkSelected;
public TaskbarWirelessNetworkButton(IWirelessNetwork network)
{
this.network = network;
InitializeComponent();
InitializeEvents();
InitializeNetworkButton();
}
private void InitializeEvents()
private void InitializeNetworkButton()
{
Button.Click += (o, args) => NetworkSelected?.Invoke(network.Id);
Button.Click += (o, args) => NetworkSelected?.Invoke(this, EventArgs.Empty);
IsCurrentTextBlock.Visibility = network.Status == WirelessNetworkStatus.Connected ? Visibility.Visible : Visibility.Hidden;
NetworkNameTextBlock.Text = network.Name;
SignalStrengthTextBlock.Text = $"{network.SignalStrength}%";
}
}
}

View file

@ -7,108 +7,35 @@
*/
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using FontAwesome.WPF;
using SafeExamBrowser.SystemComponents.Contracts;
using SafeExamBrowser.I18n.Contracts;
using SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork;
using SafeExamBrowser.UserInterface.Contracts.Shell;
using SafeExamBrowser.UserInterface.Contracts.Shell.Events;
using SafeExamBrowser.UserInterface.Shared.Utilities;
namespace SafeExamBrowser.UserInterface.Mobile.Controls
{
public partial class TaskbarWirelessNetworkControl : UserControl, ISystemWirelessNetworkControl
public partial class TaskbarWirelessNetworkControl : UserControl, ISystemControl
{
public bool HasWirelessNetworkAdapter
private IWirelessAdapter wirelessAdapter;
private IText text;
public TaskbarWirelessNetworkControl(IWirelessAdapter wirelessAdapter, IText text)
{
set
{
Dispatcher.InvokeAsync(() =>
{
Button.IsEnabled = value;
NoAdapterIcon.Visibility = value ? Visibility.Collapsed : Visibility.Visible;
});
}
}
this.wirelessAdapter = wirelessAdapter;
this.text = text;
public bool IsConnecting
{
set
{
Dispatcher.Invoke(() =>
{
LoadingIcon.Visibility = value ? Visibility.Visible : Visibility.Collapsed;
SignalStrengthIcon.Visibility = value ? Visibility.Collapsed : Visibility.Visible;
NetworkStatusIcon.Visibility = value ? Visibility.Collapsed : Visibility.Visible;
});
}
}
public WirelessNetworkStatus NetworkStatus
{
set
{
Dispatcher.InvokeAsync(() =>
{
var icon = value == WirelessNetworkStatus.Connected ? FontAwesomeIcon.Check : FontAwesomeIcon.Close;
var brush = value == WirelessNetworkStatus.Connected ? Brushes.Green : Brushes.Orange;
if (value == WirelessNetworkStatus.Disconnected)
{
SignalStrengthIcon.Child = GetIcon(0);
}
NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(icon, brush);
});
}
}
public event WirelessNetworkSelectedEventHandler NetworkSelected;
public TaskbarWirelessNetworkControl()
{
InitializeComponent();
InitializeWirelessNetworkControl();
}
public void Close()
{
Popup.IsOpen = false;
}
public void SetInformation(string text)
{
Dispatcher.InvokeAsync(() => Button.ToolTip = text);
}
public void Update(IEnumerable<IWirelessNetwork> networks)
{
Dispatcher.InvokeAsync(() =>
{
NetworksStackPanel.Children.Clear();
foreach (var network in networks)
{
var button = new TaskbarWirelessNetworkButton(network);
var isCurrent = network.Status == WirelessNetworkStatus.Connected;
button.IsCurrent = isCurrent;
button.NetworkName = network.Name;
button.SignalStrength = network.SignalStrength;
button.NetworkSelected += (id) => NetworkSelected?.Invoke(id);
if (isCurrent)
{
NetworkStatus = network.Status;
SignalStrengthIcon.Child = GetIcon(network.SignalStrength);
}
NetworksStackPanel.Children.Add(button);
}
});
Dispatcher.InvokeAsync(() => Popup.IsOpen = false);
}
private void InitializeWirelessNetworkControl()
@ -131,12 +58,90 @@ namespace SafeExamBrowser.UserInterface.Mobile.Controls
Background = originalBrush;
Button.Background = originalBrush;
};
if (wirelessAdapter.IsAvailable)
{
wirelessAdapter.NetworksChanged += WirelessAdapter_NetworksChanged;
wirelessAdapter.StatusChanged += WirelessAdapter_StatusChanged;
UpdateNetworks();
}
else
{
Button.IsEnabled = false;
NoAdapterIcon.Visibility = Visibility.Visible;
UpdateText(text.Get(TextKey.SystemControl_WirelessNotAvailable));
}
}
private void WirelessAdapter_NetworksChanged()
{
Dispatcher.InvokeAsync(UpdateNetworks);
}
private void WirelessAdapter_StatusChanged(WirelessNetworkStatus status)
{
Dispatcher.InvokeAsync(() => UpdateStatus(status));
}
private void UpdateNetworks()
{
var status = WirelessNetworkStatus.Disconnected;
NetworksStackPanel.Children.Clear();
foreach (var network in wirelessAdapter.GetNetworks())
{
var button = new TaskbarWirelessNetworkButton(network);
button.NetworkSelected += (o, args) => wirelessAdapter.Connect(network.Id);
if (network.Status == WirelessNetworkStatus.Connected)
{
status = WirelessNetworkStatus.Connected;
SignalStrengthIcon.Child = GetIcon(network.SignalStrength);
UpdateText(text.Get(TextKey.SystemControl_WirelessConnected).Replace("%%NAME%%", network.Name));
}
NetworksStackPanel.Children.Add(button);
}
UpdateStatus(status);
}
private void UpdateStatus(WirelessNetworkStatus status)
{
LoadingIcon.Visibility = Visibility.Collapsed;
SignalStrengthIcon.Visibility = Visibility.Visible;
NetworkStatusIcon.Visibility = Visibility.Visible;
switch (status)
{
case WirelessNetworkStatus.Connected:
NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Check, Brushes.Green);
break;
case WirelessNetworkStatus.Connecting:
LoadingIcon.Visibility = Visibility.Visible;
SignalStrengthIcon.Visibility = Visibility.Collapsed;
NetworkStatusIcon.Visibility = Visibility.Collapsed;
UpdateText(text.Get(TextKey.SystemControl_WirelessConnecting));
break;
default:
NetworkStatusIcon.Source = ImageAwesome.CreateImageSource(FontAwesomeIcon.Close, Brushes.Orange);
SignalStrengthIcon.Child = GetIcon(0);
UpdateText(text.Get(TextKey.SystemControl_WirelessDisconnected));
break;
}
}
private void UpdateText(string text)
{
Button.ToolTip = text;
}
private UIElement GetIcon(int signalStrength)
{
var icon = signalStrength > 66 ? "100" : (signalStrength > 33 ? "66" : (signalStrength > 0 ? "33" : "0"));
var uri = new Uri($"pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/WiFi_{icon}.xaml");
var uri = new Uri($"pack://application:,,,/SafeExamBrowser.UserInterface.Mobile;component/Images/WiFi_{icon}.xaml");
var resource = new XamlIconResource(uri);
return IconResourceLoader.Load(resource);

View file

@ -353,38 +353,38 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Images\WiFi_Light_66.xaml">
<Resource Include="Images\WiFi_Light_66.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Images\WiFi_Light_33.xaml">
</Resource>
<Resource Include="Images\WiFi_Light_33.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Images\WiFi_Light_100.xaml">
</Resource>
<Resource Include="Images\WiFi_Light_100.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Images\WiFi_Light_0.xaml">
</Resource>
<Resource Include="Images\WiFi_Light_0.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Images\WiFi_66.xaml">
</Resource>
<Resource Include="Images\WiFi_66.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Images\WiFi_33.xaml">
</Resource>
<Resource Include="Images\WiFi_33.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Images\WiFi_100.xaml">
</Resource>
<Resource Include="Images\WiFi_100.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Images\WiFi_0.xaml">
</Resource>
<Resource Include="Images\WiFi_0.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</Resource>
<Page Include="Images\SkipBack.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>

View file

@ -19,6 +19,7 @@ using SafeExamBrowser.Logging.Contracts;
using SafeExamBrowser.SystemComponents.Contracts.Audio;
using SafeExamBrowser.SystemComponents.Contracts.Keyboard;
using SafeExamBrowser.SystemComponents.Contracts.PowerSupply;
using SafeExamBrowser.SystemComponents.Contracts.WirelessNetwork;
using SafeExamBrowser.UserInterface.Contracts;
using SafeExamBrowser.UserInterface.Contracts.Browser;
using SafeExamBrowser.UserInterface.Contracts.Shell;
@ -172,15 +173,15 @@ namespace SafeExamBrowser.UserInterface.Mobile
return splashScreen;
}
public ISystemWirelessNetworkControl CreateWirelessNetworkControl(Location location)
public ISystemControl CreateWirelessNetworkControl(IWirelessAdapter wirelessAdapter, Location location)
{
if (location == Location.ActionCenter)
{
return new ActionCenterWirelessNetworkControl();
return new ActionCenterWirelessNetworkControl(wirelessAdapter, text);
}
else
{
return new TaskbarWirelessNetworkControl();
return new TaskbarWirelessNetworkControl(wirelessAdapter, text);
}
}