Esempio n. 1
0
 public void add(int batteryAmount, bool wifi, bool phone, bool location, bool isCharging, bool airplane, bool isInternetOn, bool isOverDataLimit, bool isRoaming)
 {
     SystemEndPoints.updateLockTile(batteryAmount);
     loadData();
     batteryModel.Add(new Model {
         date = DateTime.Now, quantity = batteryAmount, locationStatus = location, phoneStatus = phone, wifiStatus = wifi, isCharging = isCharging, isAirplaneOn = airplane, isInternetOn = isInternetOn, isOverDataLimit = isOverDataLimit, isRoaming = isRoaming
     });
     saveData();
 }
Esempio n. 2
0
        public void setup()
        {
            bool isCharging = SystemEndPoints.isCharging();

            if (isCharging)
            {
                string chargeString = SystemEndPoints.calculateChargeRateString("in");
                if (chargeString.Contains("calculating"))
                {
                    ChargeStatusDescription.Text = "calculating...";
                }
                else if (chargeString.Contains("fully"))
                {
                    ChargeStatusDescription.Text = "fully charged, you can unplug me";
                }
                else
                {
                    ChargeStatusDescription.Text = "fully charged in " + chargeString;
                }
            }
            else
            {
                string chargeString = SystemEndPoints.getTimeTillPowerOff();
                if (chargeString.Contains("calculating"))
                {
                    ChargeStatusDescription.Text = "calculating...";
                }
                else if (chargeString.Contains("fully"))
                {
                    ChargeStatusDescription.Text = "fully charged, you can unplug me";
                }
                else
                {
                    ChargeStatusDescription.Text = "power off in " + SystemEndPoints.getTimeTillPowerOff();
                }
            }
            ChargeStatus.Text = SystemEndPoints.currentBatteryLevel() + "%";

            double chargeLevel = SystemEndPoints.currentBatteryLevel();

            backgroundStatus.Width = (chargeLevel / 100) * 691;
        }
Esempio n. 3
0
        public List <UsageModel> getUsageModel(string type)
        {
            List <UsageModel> usageModelList = new List <UsageModel>();

            batteryModel.Reverse();

            if (type == "last charge")
            {
                int    totalCharge = SystemEndPoints.countLastChargeFactors("all");
                string description = "";
                //wifi stuff here

                int    wifiCharges   = SystemEndPoints.countLastChargeFactors("wifi");
                double wifiPerentage = ((double)wifiCharges / (double)totalCharge) * 100;
                description = "used " + wifiPerentage.ToString("0.00") + "% of the time, recorded " + wifiCharges.ToString() + " times";
                usageModelList.Add(new UsageModel {
                    name = "Wifi", quantity = (int)wifiPerentage, description = description
                });

                //mobile stuff here

                int    phoneCharges   = SystemEndPoints.countLastChargeFactors("phone");
                double phonePerentage = ((double)phoneCharges / (double)totalCharge) * 100;
                description = "used " + phonePerentage.ToString("0.00") + "% of the time, recorded " + phoneCharges.ToString() + " times";
                usageModelList.Add(new UsageModel {
                    name = "Mobile Data", quantity = (int)phonePerentage, description = description
                });

                //airplane stuff here

                int    airplaneCharges   = SystemEndPoints.countLastChargeFactors("airplane");
                double airplanePerentage = ((double)airplaneCharges / (double)totalCharge) * 100;
                description = "offline " + airplanePerentage.ToString("0.00") + "% of the time, recorded " + airplaneCharges.ToString() + " times";
                usageModelList.Add(new UsageModel {
                    name = "Airplane Mode", quantity = (int)airplanePerentage, description = description
                });

                //internet stuff here

                int    internetCharges   = SystemEndPoints.countLastChargeFactors("internet");
                double internetPerentage = ((double)internetCharges / (double)totalCharge) * 100;
                description = "used " + internetPerentage.ToString("0.00") + "% of the time, recorded " + internetCharges.ToString() + " times";
                usageModelList.Add(new UsageModel {
                    name = "Internet Access", quantity = (int)internetPerentage, description = description
                });

                //roaming stuff here

                int    roamingCharges   = SystemEndPoints.countLastChargeFactors("roaming");
                double roamingPerentage = ((double)roamingCharges / (double)totalCharge) * 100;
                description = "used " + roamingPerentage.ToString("0.00") + "% of the time, recorded " + roamingCharges.ToString() + " times";
                usageModelList.Add(new UsageModel {
                    name = "Roaming Access", quantity = (int)roamingPerentage, description = description
                });

                //over data limit stuff here

                int    overDataCharges   = SystemEndPoints.countLastChargeFactors("overData");
                double overDataPerentage = ((double)overDataCharges / (double)totalCharge) * 100;
                description = "went over " + overDataPerentage.ToString("0.00") + "% of the time, recorded " + overDataCharges.ToString() + " times";
                usageModelList.Add(new UsageModel {
                    name = "Data Limit", quantity = (int)overDataPerentage, description = description
                });
            }
            else if (type == "last 100% charge")
            {
                int    totalCharge = SystemEndPoints.countHundredChargeFactors("all");
                string description = "";
                //wifi stuff here

                int    wifiCharges   = SystemEndPoints.countHundredChargeFactors("wifi");
                double wifiPerentage = ((double)wifiCharges / (double)totalCharge) * 100;
                description = "used " + wifiPerentage.ToString("0.00") + "% of the time, recorded " + wifiCharges.ToString() + " times";
                usageModelList.Add(new UsageModel {
                    name = "Wifi", quantity = (int)wifiPerentage, description = description
                });

                //mobile stuff here

                int    phoneCharges   = SystemEndPoints.countHundredChargeFactors("phone");
                double phonePerentage = ((double)phoneCharges / (double)totalCharge) * 100;
                description = "used " + phonePerentage.ToString("0.00") + "% of the time, recorded " + phoneCharges.ToString() + " times";
                usageModelList.Add(new UsageModel {
                    name = "Mobile Data", quantity = (int)phonePerentage, description = description
                });

                //airplane stuff here

                int    airplaneCharges   = SystemEndPoints.countHundredChargeFactors("airplane");
                double airplanePerentage = ((double)airplaneCharges / (double)totalCharge) * 100;
                description = "offline " + airplanePerentage.ToString("0.00") + "% of the time, recorded " + airplaneCharges.ToString() + " times";
                usageModelList.Add(new UsageModel {
                    name = "Airplane Mode", quantity = (int)airplanePerentage, description = description
                });

                //internet stuff here

                int    internetCharges   = SystemEndPoints.countHundredChargeFactors("internet");
                double internetPerentage = ((double)internetCharges / (double)totalCharge) * 100;
                description = "used " + internetPerentage.ToString("0.00") + "% of the time, recorded " + internetCharges.ToString() + " times";
                usageModelList.Add(new UsageModel {
                    name = "Internet Access", quantity = (int)internetPerentage, description = description
                });

                //roaming stuff here

                int    roamingCharges   = SystemEndPoints.countHundredChargeFactors("roaming");
                double roamingPerentage = ((double)roamingCharges / (double)totalCharge) * 100;
                description = "used " + roamingPerentage.ToString("0.00") + "% of the time, recorded " + roamingCharges.ToString() + " times";
                usageModelList.Add(new UsageModel {
                    name = "Roaming Access", quantity = (int)roamingPerentage, description = description
                });

                //over data limit stuff here

                int    overDataCharges   = SystemEndPoints.countHundredChargeFactors("overData");
                double overDataPerentage = ((double)overDataCharges / (double)totalCharge) * 100;
                description = "went over " + overDataPerentage.ToString("0.00") + "% of the time, recorded " + overDataCharges.ToString() + " times";
                usageModelList.Add(new UsageModel {
                    name = "Data Limit", quantity = (int)overDataPerentage, description = description
                });
            }
            else
            {
                int    totalCharge = SystemEndPoints.countAllTimeFactors("all");
                string description = "";
                //wifi stuff here

                int    wifiCharges   = SystemEndPoints.countAllTimeFactors("wifi");
                double wifiPerentage = ((double)wifiCharges / (double)totalCharge) * 100;
                description = "used " + wifiPerentage.ToString("0.00") + "% of the time, recorded " + wifiCharges.ToString() + " times";
                usageModelList.Add(new UsageModel {
                    name = "Wifi", quantity = (int)wifiPerentage, description = description
                });

                //mobile stuff here

                int    phoneCharges   = SystemEndPoints.countAllTimeFactors("phone");
                double phonePerentage = ((double)phoneCharges / (double)totalCharge) * 100;
                description = "used " + phonePerentage.ToString("0.00") + "% of the time, recorded " + phoneCharges.ToString() + " times";
                usageModelList.Add(new UsageModel {
                    name = "Mobile Data", quantity = (int)phonePerentage, description = description
                });

                //airplane stuff here

                int    airplaneCharges   = SystemEndPoints.countAllTimeFactors("airplane");
                double airplanePerentage = ((double)airplaneCharges / (double)totalCharge) * 100;
                description = "offline " + airplanePerentage.ToString("0.00") + "% of the time, recorded " + airplaneCharges.ToString() + " times";
                usageModelList.Add(new UsageModel {
                    name = "Airplane Mode", quantity = (int)airplanePerentage, description = description
                });

                //internet stuff here

                int    internetCharges   = SystemEndPoints.countAllTimeFactors("internet");
                double internetPerentage = ((double)internetCharges / (double)totalCharge) * 100;
                description = "used " + internetPerentage.ToString("0.00") + "% of the time, recorded " + internetCharges.ToString() + " times";
                usageModelList.Add(new UsageModel {
                    name = "Internet Access", quantity = (int)internetPerentage, description = description
                });

                //roaming stuff here

                int    roamingCharges   = SystemEndPoints.countAllTimeFactors("roaming");
                double roamingPerentage = ((double)roamingCharges / (double)totalCharge) * 100;
                description = "used " + roamingPerentage.ToString("0.00") + "% of the time, recorded " + roamingCharges.ToString() + " times";
                usageModelList.Add(new UsageModel {
                    name = "Roaming Access", quantity = (int)roamingPerentage, description = description
                });

                //over data limit stuff here

                int    overDataCharges   = SystemEndPoints.countAllTimeFactors("overData");
                double overDataPerentage = ((double)overDataCharges / (double)totalCharge) * 100;
                description = "went over " + overDataPerentage.ToString("0.00") + "% of the time, recorded " + overDataCharges.ToString() + " times";
                usageModelList.Add(new UsageModel {
                    name = "Data Limit", quantity = (int)overDataPerentage, description = description
                });
            }

            batteryModel.Reverse();
            //detailedModelList.Reverse();

            return(usageModelList);
        }