2017-08-23 10:30:27 +02:00
|
|
|
|
/*
|
2019-01-09 11:25:21 +01:00
|
|
|
|
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
2017-08-23 10:30:27 +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.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Media;
|
2019-08-30 09:55:26 +02:00
|
|
|
|
using SafeExamBrowser.SystemComponents.Contracts;
|
|
|
|
|
using SafeExamBrowser.UserInterface.Contracts.Shell;
|
2017-08-23 10:30:27 +02:00
|
|
|
|
|
2019-01-11 15:32:47 +01:00
|
|
|
|
namespace SafeExamBrowser.UserInterface.Desktop.Controls
|
2017-08-23 10:30:27 +02:00
|
|
|
|
{
|
2019-03-14 10:28:21 +01:00
|
|
|
|
public partial class ActionCenterPowerSupplyControl : UserControl, ISystemPowerSupplyControl
|
2017-08-23 10:30:27 +02:00
|
|
|
|
{
|
|
|
|
|
private double BATTERY_CHARGE_MAX_WIDTH;
|
|
|
|
|
|
2019-03-14 10:28:21 +01:00
|
|
|
|
public ActionCenterPowerSupplyControl()
|
2017-08-23 10:30:27 +02:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
BATTERY_CHARGE_MAX_WIDTH = BatteryCharge.Width;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Close()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetBatteryCharge(double charge, BatteryChargeStatus status)
|
|
|
|
|
{
|
2019-01-23 14:18:44 +01:00
|
|
|
|
Dispatcher.InvokeAsync(() =>
|
2017-08-23 10:30:27 +02:00
|
|
|
|
{
|
|
|
|
|
var width = BATTERY_CHARGE_MAX_WIDTH * charge;
|
|
|
|
|
|
|
|
|
|
width = width > BATTERY_CHARGE_MAX_WIDTH ? BATTERY_CHARGE_MAX_WIDTH : width;
|
|
|
|
|
width = width < 0 ? 0 : width;
|
|
|
|
|
|
|
|
|
|
BatteryCharge.Width = width;
|
|
|
|
|
BatteryCharge.Fill = status == BatteryChargeStatus.Low ? Brushes.Orange : BatteryCharge.Fill;
|
|
|
|
|
BatteryCharge.Fill = status == BatteryChargeStatus.Critical ? Brushes.Red : BatteryCharge.Fill;
|
|
|
|
|
Warning.Visibility = status == BatteryChargeStatus.Critical ? Visibility.Visible : Visibility.Collapsed;
|
2019-01-23 14:18:44 +01:00
|
|
|
|
});
|
2017-08-23 10:30:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetPowerGridConnection(bool connected)
|
|
|
|
|
{
|
2019-01-23 14:18:44 +01:00
|
|
|
|
Dispatcher.InvokeAsync(() => PowerPlug.Visibility = connected ? Visibility.Visible : Visibility.Collapsed);
|
2017-08-23 10:30:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-14 10:28:21 +01:00
|
|
|
|
public void SetInformation(string text)
|
2017-08-23 10:30:27 +02:00
|
|
|
|
{
|
2019-03-14 10:28:21 +01:00
|
|
|
|
Dispatcher.InvokeAsync(() => Text.Text = text);
|
2017-08-23 10:30:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ShowCriticalBatteryWarning(string warning)
|
|
|
|
|
{
|
2019-03-14 10:28:21 +01:00
|
|
|
|
Dispatcher.InvokeAsync(() => Button.ToolTip = warning);
|
2017-08-23 10:30:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ShowLowBatteryInfo(string info)
|
|
|
|
|
{
|
2019-03-14 10:28:21 +01:00
|
|
|
|
Dispatcher.InvokeAsync(() => Button.ToolTip = info);
|
2017-08-23 10:30:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|