Minor refactoring.

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

View file

@ -78,6 +78,22 @@ namespace SafeExamBrowser.SystemComponents
var hours = SystemInformation.PowerStatus.BatteryLifeRemaining / 3600;
var minutes = (SystemInformation.PowerStatus.BatteryLifeRemaining - (hours * 3600)) / 60;
HandleBatteryStatus(status);
tooltip = text.Get(TextKey.SystemControl_BatteryRemainingCharge);
tooltip = tooltip.Replace("%%HOURS%%", hours.ToString());
tooltip = tooltip.Replace("%%MINUTES%%", minutes.ToString());
}
tooltip = tooltip.Replace("%%CHARGE%%", percentage.ToString());
control.SetBatteryCharge(charge, status);
control.SetPowerGridConnection(online);
control.SetTooltip(tooltip);
}
private void HandleBatteryStatus(BatteryChargeStatus status)
{
if (status == BatteryChargeStatus.Low && !infoShown)
{
control.ShowLowBatteryInfo(text.Get(TextKey.SystemControl_BatteryChargeLowInfo));
@ -91,17 +107,6 @@ namespace SafeExamBrowser.SystemComponents
warningShown = true;
logger.Warn("Warned the user about critical battery charge.");
}
tooltip = text.Get(TextKey.SystemControl_BatteryRemainingCharge);
tooltip = tooltip.Replace("%%HOURS%%", hours.ToString());
tooltip = tooltip.Replace("%%MINUTES%%", minutes.ToString());
}
tooltip = tooltip.Replace("%%CHARGE%%", percentage.ToString());
control.SetBatteryCharge(charge, status);
control.SetPowerGridConnection(online);
control.SetTooltip(tooltip);
}
}
}