Esempio n. 1
0
 protected virtual void OnBatteryStateChanged(BatteryEventArgs e)
 {
     BatteryStateChanged.Raise(this, e);
     Logging.LoggingManager.LogEvent(Logging.LogEventType.DEBUG, "BatteryState changed: " + e.BatteryState);
     if(e.ChargingState == ChargingState.OnBattery)
         Logging.LoggingManager.LogEvent(Logging.LogEventType.DEBUG, "Battery remaining: " + e.BatteryRemaining);
 }
Esempio n. 2
0
 private void OnBatteryStateChanged(object sender, BatteryEventArgs e)
 {
     UpdateStatusBarBatteryState(e.BatteryState);        // TODO: might want to save this state and compare to save time
     UpdateBatteryToolTipText(e.BatteryRemaining);
 }
Esempio n. 3
0
        private void UpdateBatteryState()
        {
            bool isChargingNow = (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online); // TODO: PowerLineStatus.Unknown wird nicht behandelt |f| würde es so lassen
            short batteryStateNow = (short)Math.Floor(SystemInformation.PowerStatus.BatteryLifePercent * 100f);
            int batteryRemaining = SystemInformation.PowerStatus.BatteryLifeRemaining;

            if (_isCharging != isChargingNow || _batteryState != batteryStateNow || batteryRemaining != _batteryRemaining)
            {
                BatteryEventArgs args = new BatteryEventArgs()
                {
                    BatteryState = CalculateBatteryState(batteryStateNow),
                    ChargingState = CalculateChargingState(isChargingNow),
                    BatteryRemaining = CalculateBatteryRemaining(batteryRemaining)
                };
                OnBatteryStateChanged(args);

                _isCharging = isChargingNow;
                _batteryState = batteryStateNow;
                _batteryRemaining = batteryRemaining;
            }
        }