コード例 #1
0
ファイル: BeFit_Form.cs プロジェクト: SebastianZaczek/BeFit
        private void SummarizeToday()
        {
            int index = List_Indexator.ReturnTodaysMealIndex(ActiveProfile.List_Of_meals);
            // int index = ActiveProfile.List_Of_meals.FindIndex(x => x.Date.Date == DateTime.Today);
            Day_Meals day_meal = ActiveProfile.List_Of_meals[index];
            double    KCAL = 0, Fat = 0, Carbo = 0, Protein = 0, Sugar = 0, FatSaturated = 0;

            foreach (Meal meal in day_meal.Meals)
            {
                foreach (Product_Mass product in meal.Products)
                {
                    KCAL         += product.Product.Total_kcal_per_100 * (product.Mass / 100);
                    Fat          += product.Product.Fat_Total * (product.Mass / 100);
                    Carbo        += product.Product.Carbohydrates * (product.Mass / 100);
                    Protein      += product.Product.Protein * (product.Mass / 100);
                    Sugar        += (double)product.Product.Carbo_Sugar * (product.Mass / 100);
                    FatSaturated += (double)product.Product.Fat_Saturated * (product.Mass / 100);
                }
            }

            Kcal_Progressbar.ChangeControlValue(KCAL, day_meal.CaloricDemand, "kcal");
            FatProgressBar.ChangeControlValue(Fat, day_meal.FatDemand, "g");
            Protein_ProgressBar.ChangeControlValue(Protein, day_meal.ProteinDemand, "g");
            Carbo_Progressbar.ChangeControlValue(Carbo, day_meal.CarboDemand, "g");
            double accuracy = ((AccuracyAbs.ReturnDiffrence(KCAL / (day_meal.CaloricDemand / 100))) +
                               (AccuracyAbs.ReturnDiffrence(Fat / (day_meal.FatDemand / 100))) +
                               (AccuracyAbs.ReturnDiffrence(Carbo / (day_meal.CarboDemand / 100))) +
                               (AccuracyAbs.ReturnDiffrence(Protein / (day_meal.ProteinDemand / 100)))) / 4;

            AvarageAccuracy_ProgressBar.ChangeControlValue_Accuracy(accuracy);
            TodayFatSat_Label.Text     = Math.Round(FatSaturated, 1).ToString() + " g";
            TodayCarboSugar_Label.Text = Math.Round(Sugar, 1).ToString() + " g";
        }
コード例 #2
0
        private void OwnInitializeCompomponents(Day_Meals daymeal)
        {
            KcalDemand_Label.Text    = Math.Round(daymeal.CaloricDemand, 1).ToString() + " kcal";
            FatDemand_Label.Text     = Math.Round(daymeal.FatDemand, 1).ToString() + " g";
            CarboDemand_Label.Text   = Math.Round(daymeal.CarboDemand, 1).ToString() + " g";
            ProteinDemand_Label.Text = Math.Round(daymeal.ProteinDemand, 1).ToString() + " g";
            double kcal = 0, fat = 0, carbo = 0, protein = 0;

            foreach (Meal meal in daymeal.Meals)
            {
                foreach (Product_Mass product in meal.Products)
                {
                    kcal    += product.Product.Total_kcal_per_100 * (product.Mass / 100);
                    fat     += product.Product.Fat_Total * (product.Mass / 100);
                    carbo   += product.Product.Carbohydrates * (product.Mass / 100);
                    protein += product.Product.Protein * (product.Mass / 100);
                }
            }
            KcalEaten_Label.Text    = Math.Round(kcal, 1).ToString() + " kcal";
            FatEaten_Label.Text     = Math.Round(fat, 1).ToString() + " g";
            CarboEaten_Label.Text   = Math.Round(carbo, 1).ToString() + " g";
            ProteinEaten_Label.Text = Math.Round(protein, 1).ToString() + " g";

            double accuracy = ((AccuracyAbs.ReturnDiffrence(kcal / (daymeal.CaloricDemand / 100))) +
                               (AccuracyAbs.ReturnDiffrence(fat / (daymeal.FatDemand / 100))) +
                               (AccuracyAbs.ReturnDiffrence(carbo / (daymeal.CarboDemand / 100))) +
                               (AccuracyAbs.ReturnDiffrence(protein / (daymeal.ProteinDemand / 100)))) / 4;

            Date_Label.Text      = daymeal.Date.Date.ToShortDateString() + " | " + ((int)accuracy).ToString() + " %";
            Date_Label.BackColor = ReturnColorProgress.ReturnColor(accuracy);
        }
コード例 #3
0
        public void ChangeControlValue_Accuracy(double accuracy)
        {
            accuracy = AccuracyAbs.ReturnDiffrence(accuracy);
            this.PercentValue_ProgressBar.Style = ReturnColorProgress.ReturnMetroColor(accuracy);

            this.GramValue_Label.Text  = "";
            this.OverHunder_Label.Text = ((int)accuracy).ToString() + "%";
            if (accuracy > 100)  // cap na value progress bar
            {
                accuracy = 100;
            }
            else if (accuracy < 0)
            {
                accuracy = 100;
            }
            this.PercentValue_ProgressBar.Value = (int)accuracy;
        }
コード例 #4
0
        public void ReturnDiffrence_MainValueIsEqual100()
        {
            double value = AccuracyAbs.ReturnDiffrence(100);

            Assert.That(value == 100);
        }
コード例 #5
0
 public double ReturnDiffrence_MainValueIsHigherThan100_ReturnAbs(double value)
 {
     value = AccuracyAbs.ReturnDiffrence(value);
     return(value);
 }
コード例 #6
0
 public double ReturnDiffrence_MainValueIsLoverThat100_ReturnValue(double value)
 {
     value = AccuracyAbs.ReturnDiffrence(value);
     return(value);
 }