Minor refactoring.
This commit is contained in:
parent
4e8bf23240
commit
ce62576ba4
1 changed files with 18 additions and 13 deletions
|
@ -78,19 +78,7 @@ namespace SafeExamBrowser.SystemComponents
|
||||||
var hours = SystemInformation.PowerStatus.BatteryLifeRemaining / 3600;
|
var hours = SystemInformation.PowerStatus.BatteryLifeRemaining / 3600;
|
||||||
var minutes = (SystemInformation.PowerStatus.BatteryLifeRemaining - (hours * 3600)) / 60;
|
var minutes = (SystemInformation.PowerStatus.BatteryLifeRemaining - (hours * 3600)) / 60;
|
||||||
|
|
||||||
if (status == BatteryChargeStatus.Low && !infoShown)
|
HandleBatteryStatus(status);
|
||||||
{
|
|
||||||
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.");
|
|
||||||
}
|
|
||||||
|
|
||||||
tooltip = text.Get(TextKey.SystemControl_BatteryRemainingCharge);
|
tooltip = text.Get(TextKey.SystemControl_BatteryRemainingCharge);
|
||||||
tooltip = tooltip.Replace("%%HOURS%%", hours.ToString());
|
tooltip = tooltip.Replace("%%HOURS%%", hours.ToString());
|
||||||
|
@ -103,5 +91,22 @@ namespace SafeExamBrowser.SystemComponents
|
||||||
control.SetPowerGridConnection(online);
|
control.SetPowerGridConnection(online);
|
||||||
control.SetTooltip(tooltip);
|
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.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue