private void UpdatePercentage()
        {
            var batteryReport = Windows.Devices.Power.Battery.AggregateBattery.GetReport();

            if (batteryReport.FullChargeCapacityInMilliwattHours != null && batteryReport.RemainingCapacityInMilliwattHours != null)
            {
                var percentage = (batteryReport.RemainingCapacityInMilliwattHours.Value /
                    (double)batteryReport.FullChargeCapacityInMilliwattHours.Value) * 100;

                if (percentage <= 100 && percentage > 80)
                {
                    _batteryPercentageState = BaterryPercentageState.VeryHight;
                }
                else if (percentage <= 80 && percentage > 60)
                {
                    _batteryPercentageState = BaterryPercentageState.Hight;
                }
                else if (percentage <= 60 && percentage > 40)
                {
                    _batteryPercentageState = BaterryPercentageState.Medium;
                }
                else if (percentage <= 40 && percentage > 20)
                {
                    _batteryPercentageState = BaterryPercentageState.Low;
                }
                else if (percentage <= 20 && percentage > 1)
                {
                    _batteryPercentageState = BaterryPercentageState.Verylow;
                }
                else
                {
                    _batteryPercentageState = BaterryPercentageState.Unknown;
                }
            }
        }
Beispiel #2
0
        private void UpdatePercentage()
        {
            var batteryReport = Windows.Devices.Power.Battery.AggregateBattery.GetReport();

            if (batteryReport.FullChargeCapacityInMilliwattHours != null && batteryReport.RemainingCapacityInMilliwattHours != null)
            {
                var percentage = (batteryReport.RemainingCapacityInMilliwattHours.Value /
                                  (double)batteryReport.FullChargeCapacityInMilliwattHours.Value) * 100;

                if (percentage <= 100 && percentage > 80)
                {
                    _batteryPercentageState = BaterryPercentageState.VeryHight;
                }
                else if (percentage <= 80 && percentage > 60)
                {
                    _batteryPercentageState = BaterryPercentageState.Hight;
                }
                else if (percentage <= 60 && percentage > 40)
                {
                    _batteryPercentageState = BaterryPercentageState.Medium;
                }
                else if (percentage <= 40 && percentage > 20)
                {
                    _batteryPercentageState = BaterryPercentageState.Low;
                }
                else if (percentage <= 20 && percentage > 1)
                {
                    _batteryPercentageState = BaterryPercentageState.Verylow;
                }
                else
                {
                    _batteryPercentageState = BaterryPercentageState.Unknown;
                }
            }
        }