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"; }
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); }
private void LoadLastDemands_Click(object sender, EventArgs e) { ListOfDayMeals.Sort((x, y) => x.Date.CompareTo(y.Date)); //sprawdzic czy przesylane listy sa posortowane Day_Meals p = ListOfDayMeals[ListOfDayMeals.Count - 1]; DayMeal = new Day_Meals(p.CaloricDemand, p.FatDemand, p.CarboDemand, p.ProteinDemand); this.DialogResult = DialogResult.OK; this.Close(); }
public void ReturnTodayMealIndex_AddsAFewDayMeals_ReturnADayMealWithTodaysDate() { List <Day_Meals> list = new List <Day_Meals>(); list.Add(new Day_Meals(DateTime.Now.AddDays(2))); var now = new Day_Meals(DateTime.Now); list.Add(now); list.Add(new Day_Meals(DateTime.Now.AddDays(-2))); list.Add(new Day_Meals(DateTime.Now.AddDays(1))); int index = List_Indexator.ReturnTodaysMealIndex(list); Assert.That(index == list.IndexOf(now)); }
private void AddProfile_Button_Click(object sender, EventArgs e) { if (Convert.ToInt32(Percent_Label.Text) != 0) { new GiveUserInfo_Form(true, "Wprowadź prawidłowy procentowy rozkład makroskładników"); } else { double kcal = Convert.ToDouble(CaloricDemand_Textbox.Text); DayMeal = new Day_Meals(kcal, kcal / 100 * Convert.ToDouble(FatDemand_Textbox.Text) / 9, kcal / 100 * Convert.ToDouble(CarboDemand_Textbox.Text) / 4, kcal / 100 * Convert.ToDouble(ProteinDemand_Textbox.Text) / 4); this.DialogResult = DialogResult.OK; this.Close(); } }
private void AddProfile_Button_Click(object sender, EventArgs e) { bool IsNameValid = true; string[] files = GetProfilesNames(); string pom; string name = ProfileName_TextBox.Text; if (name.Length < 3) { new GiveUserInfo_Form(true, "Nazwa powinna składać się przynajmniej z 3 znaków"); } else if (Convert.ToInt32(Percent_Label.Text) != 0) { new GiveUserInfo_Form(true, "Wprowadź prawidłowy procentowy rozkład makroskładników"); } else { foreach (string s in files) // sprawdza czy nie ma takiej nazwy profilu { pom = Path.GetFileNameWithoutExtension(s); if (name == pom) { IsNameValid = false; new GiveUserInfo_Form(true, "Wprowadzona nazwa profilu już istnieje"); break; } } if (IsNameValid == true) { double[] tab = CalculateDemandInGrams.CaltulateIngredients(Convert.ToDouble(CaloricDemand_Textbox.Text), Convert.ToDouble(FatDemand_Textbox.Text), Convert.ToDouble(CarboDemand_Textbox.Text), Convert.ToDouble(ProteinDemand_Textbox.Text)); Day_Meals DayMeal = new Day_Meals(Convert.ToDouble(CaloricDemand_Textbox.Text), tab[0], tab[1], tab[2]); Profile profile = new Profile(name); profile.List_Of_meals.Add(DayMeal); BeFit_Form form = new BeFit_Form(profile); form.Show(); this.Close(); } } }
public Summary_Control(Day_Meals daymeal) { InitializeComponent(); OwnInitializeCompomponents(daymeal); }