Ejemplo n.º 1
0
        private void AddToEaten(Aliment a, int quantity, bool addInFile)
        {
            ListViewItem pula = new ListViewItem(a.FoodName);

            pula.SubItems.Add(quantity.ToString());

            float calPer100    = a.Calories;
            float protPer100   = a.Proteins;
            float carbsPer100  = a.Carbs;
            float lipidsPer100 = a.Lipids;
            float fibersPer100 = a.Fibers;

            pula.SubItems.Add(Math.Round(calPer100 * quantity / 100, 2).ToString());
            pula.SubItems.Add(Math.Round(protPer100 * quantity / 100, 2).ToString());
            pula.SubItems.Add(Math.Round(carbsPer100 * quantity / 100, 2).ToString());
            pula.SubItems.Add(Math.Round(lipidsPer100 * quantity / 100, 2).ToString());
            pula.SubItems.Add(Math.Round(fibersPer100 * quantity / 100, 2).ToString());

            listEaten.Items.Add(pula);

            UpdateStats();
            RefreshGoals();

            eatenAliments.Add(a);
            eatenQuantities.Add(quantity);

            if (addInFile)
            {
                Aliment.addFoodInFile(eatenAliments, eatenQuantities,
                                      new float[] { currentCalories, currentProteins, currentCarbs, currentLipids, currentFibers });
            }
        }
Ejemplo n.º 2
0
 private void listEaten_DoubleClick(object sender, EventArgs e)
 {
     if (listEaten.SelectedIndices.Count > 0)
     {
         int toRemove = listEaten.SelectedIndices[0];
         listEaten.Items.RemoveAt(toRemove);
         eatenAliments.RemoveAt(toRemove);
         eatenQuantities.RemoveAt(toRemove);
         UpdateStats();
         RefreshGoals();
         Aliment.addFoodInFile(eatenAliments, eatenQuantities,
                               new float[] { currentCalories, currentProteins, currentCarbs, currentLipids, currentFibers });
     }
 }