Example #1
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);
        }
Example #2
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;
        }
Example #3
0
        public void ChangeControlValue(double value, double gramsdemand, string suffix)
        {
            double percents = value / (gramsdemand / 100);

            this.PercentValue_ProgressBar.Style = ReturnColorProgress.ReturnMetroColor(percents);


            if (percents > 100)
            {
                this.PercentValue_ProgressBar.Value = 100;
            }
            else
            {
                this.PercentValue_ProgressBar.Value = (int)percents;
            }
            this.GramValue_Label.Text  = Math.Round(value, 1).ToString() + " " + suffix;
            this.OverHunder_Label.Text = ((int)percents).ToString() + "%";
        }