private static void PowerManager_EnergySaverStatusChanged(object sender, object e)
        {
            EnergySaverStatus energyStatus = PowerManager.EnergySaverStatus;

            OutputMessage($"Energy saver status changed: {energyStatus}");
            DetermineWorkloads();
        }
Example #2
0
        void showActualBatteryState(double chargeLevel,
                                    BatteryPowerSource batteryPowerSource,
                                    BatteryState batteryState,
                                    EnergySaverStatus energySaverStatus)
        {
            labelCharge.Text = string.Format("{0}%", chargeLevel * 100);

            switch (batteryPowerSource)
            {
            case BatteryPowerSource.Battery:
                labelPowerSource.Text = "Batterie";
                break;

            case BatteryPowerSource.AC:
                labelPowerSource.Text = "Stromnetz";
                break;

            case BatteryPowerSource.Usb:
                labelPowerSource.Text = "USB-Anschluss";
                break;

            case BatteryPowerSource.Wireless:
                labelPowerSource.Text = "drahtlos";
                break;

            case BatteryPowerSource.Unknown:
                labelPowerSource.Text = "unbekannt";
                break;
            }

            switch (batteryState)
            {
            case BatteryState.Full:             // 5
                labelBatteryState.Text = "voll geladen";
                break;

            case BatteryState.Discharging:      // 3
                labelBatteryState.Text = "wird entladen";
                break;

            case BatteryState.Charging:         // 2
                labelBatteryState.Text = "wird geladen";
                break;

            case BatteryState.NotCharging:      // 4
                labelBatteryState.Text = "wird NICHT geladen";
                break;

            case BatteryState.NotPresent:
                labelBatteryState.Text = "keine Batterie vorhanden";
                break;

            case BatteryState.Unknown:
                labelBatteryState.Text = "unbekannt";
                break;
            }

            switch (energySaverStatus)
            {
            case EnergySaverStatus.Off:
                labelEnergySaverStatus.Text = "aus";
                break;

            case EnergySaverStatus.On:
                labelEnergySaverStatus.Text = "ein";
                break;

            case EnergySaverStatus.Unknown:
                labelEnergySaverStatus.Text = "unbekannt";
                break;
            }

            DependencyService.Get <IBatteryInfo>().GetAndroidBatteryExtendedData(out int health, out float temperature, out string technology, out long chargetimeremaining);
            string sHealth;

            switch (health)
            {
            case 1: // BATTERY_HEALTH_UNKNOWN
            default:
                sHealth = "unbekannt";
                break;

            case 2: // BATTERY_HEALTH_GOOD
                sHealth = "gut";
                break;

            case 3: // BATTERY_HEALTH_OVERHEAT
                sHealth = "schlecht (überhitzt)";
                break;

            case 4: // BATTERY_HEALTH_DEAD
                sHealth = "schlecht";
                break;

            case 5: // BATTERY_HEALTH_OVER_VOLTAGE
                sHealth = "schlecht (überladen)";
                break;

            case 6: // BATTERY_HEALTH_UNSPECIFIED_FAILURE
                sHealth = "Fehler";
                break;

            case 7: // BATTERY_HEALTH_COLD
                sHealth = "gut (kalt)";
                break;
            }

            string sChargetimeremaining = "";

            if (chargetimeremaining > 0)
            {
                sChargetimeremaining = ", verbleidende Ladezeit " + (chargetimeremaining / 60000).ToString() + " min";
            }

            labelExtendedData.Text = string.Format("„Batteriegesundheit“ {0}, Temperatur {1}°C{2}, {3}",
                                                   sHealth,
                                                   temperature / 10,
                                                   sChargetimeremaining,
                                                   technology);
        }
Example #3
0
 public EnergySaverStatusChangedEventArgs(EnergySaverStatus saverStatus)
 {
     EnergySaverStatus = saverStatus;
 }
Example #4
0
 static void OnEnergySaverChanged(EnergySaverStatus saverStatus)
 => OnEnergySaverChanged(new EnergySaverStatusChangedEventArgs(saverStatus));
Example #5
0
 internal EnergySaverStatusChangedEventArgs(EnergySaverStatus saverStatus)
 {
     EnergySaverStatus = saverStatus;
 }
Example #6
0
 void showEnergySaverStatus(EnergySaverStatus energySaverStatus)
 {
     labelEnergySaverStatus.Text = string.Format("Energiesparmodus: {0}", energySaverStatus.ToString());
 }