public void setup() { bool isCharging = SystemEndPoints.isCharging(); if (isCharging) { string chargeString = SystemEndPoints.calculateChargeRateString("in"); if (chargeString.Contains("calculating")) { ChargeStatusDescription.Text = "Calculating..."; Discharging.Text = "please wait"; PowerOffAt.Text = ""; } else if (chargeString.Contains("fully")) { ChargeStatusDescription.Text = "Fully charged"; Discharging.Text = "you can unplug me"; PowerOffAt.Text = ""; } else { ChargeStatusDescription.Text = "Charging..."; Discharging.Text = "fully charged in " + SystemEndPoints.calculateChargeRateString("in") + ", "; PowerOffAt.Text = "at " + SystemEndPoints.calculateChargeRateString("at");; } } else { string chargeString = SystemEndPoints.getTimeTillPowerOff(); if (chargeString.Contains("calculating")) { ChargeStatusDescription.Text = "Calculating..."; Discharging.Text = "please wait"; PowerOffAt.Text = ""; } else if (chargeString.Contains("fully")) { ChargeStatusDescription.Text = "Fully charged"; Discharging.Text = "you can unplug me"; PowerOffAt.Text = ""; } else { ChargeStatusDescription.Text = SystemEndPoints.getTimeTillPowerOff() + " left"; Discharging.Text = "discharging at " + SystemEndPoints.getTimeRatio(); PowerOffAt.Text = "power off at " + SystemEndPoints.getPowerOffTime(); } } ChargeStatus.Text = SystemEndPoints.currentBatteryLevel().ToString(); double chargeLevel = SystemEndPoints.currentBatteryLevel(); backgroundStatus.Width = (chargeLevel / 100) * 70; }
public void updateStates() { updateUI(); bool isCharging = SystemEndPoints.isCharging(); if (isCharging) { System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => { DischarginRateTitle.Text = "CHARGING RATE"; PowerOffTitle.Text = "FULL CHARGE IN"; PowerOffAtTitle.Text = "FULL CHARGE AT"; DischargeRateInput.Text = SystemEndPoints.calculateChargeRateString("rate"); powerOffInInput.Text = SystemEndPoints.calculateChargeRateString("in"); powerOffAtInput.Text = SystemEndPoints.calculateChargeRateString("at"); timeSinceLastChargeInput.Text = "currently charging..."; }); //Debug.WriteLine(SystemEndPoints.calculateChargeRate()); } else { System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() => { DischarginRateTitle.Text = "DISCHARGING RATE"; PowerOffTitle.Text = "POWER OFF"; PowerOffAtTitle.Text = "POWER OFF AT"; timeSinceLastChargeInput.Text = SystemEndPoints.timeSinceLastCharge(); DischargeRateInput.Text = SystemEndPoints.getTimeRatio(); powerOffAtInput.Text = SystemEndPoints.getPowerOffTime(); powerOffInInput.Text = SystemEndPoints.getTimeTillPowerOff(); }); } }