diff --git a/SafeExamBrowser.SystemComponents/PowerSupply.cs b/SafeExamBrowser.SystemComponents/PowerSupply.cs index 9efe70cc..6e7804a4 100644 --- a/SafeExamBrowser.SystemComponents/PowerSupply.cs +++ b/SafeExamBrowser.SystemComponents/PowerSupply.cs @@ -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."); + } + } } }