Minor refactoring.

This commit is contained in:
dbuechel 2017-08-17 15:04:19 +02:00
parent 4e8bf23240
commit ce62576ba4

View file

@ -78,19 +78,7 @@ namespace SafeExamBrowser.SystemComponents
var hours = SystemInformation.PowerStatus.BatteryLifeRemaining / 3600;
var minutes = (SystemInformation.PowerStatus.BatteryLifeRemaining - (hours * 3600)) / 60;
if (status == BatteryChargeStatus.Low && !infoShown)
{
control.ShowLowBatteryInfo(text.Get(TextKey.SystemControl_BatteryChargeLowInfo));
infoShown = true;
logger.Info("Informed the user about low battery charge.");
}
if (status == BatteryChargeStatus.Critical && !warningShown)
{
control.ShowCriticalBatteryWarning(text.Get(TextKey.SystemControl_BatteryChargeCriticalWarning));
warningShown = true;
logger.Warn("Warned the user about critical battery charge.");
}
HandleBatteryStatus(status);
tooltip = text.Get(TextKey.SystemControl_BatteryRemainingCharge);
tooltip = tooltip.Replace("%%HOURS%%", hours.ToString());
@ -103,5 +91,22 @@ namespace SafeExamBrowser.SystemComponents
control.SetPowerGridConnection(online);
control.SetTooltip(tooltip);
}
private void HandleBatteryStatus(BatteryChargeStatus status)
{
if (status == BatteryChargeStatus.Low && !infoShown)
{
control.ShowLowBatteryInfo(text.Get(TextKey.SystemControl_BatteryChargeLowInfo));
infoShown = true;
logger.Info("Informed the user about low battery charge.");
}
if (status == BatteryChargeStatus.Critical && !warningShown)
{
control.ShowCriticalBatteryWarning(text.Get(TextKey.SystemControl_BatteryChargeCriticalWarning));
warningShown = true;
logger.Warn("Warned the user about critical battery charge.");
}
}
}
}