コード例 #1
0
 public NyttReceptForm(ref List<Ingredient> FullIngrList)
 {
     InitializeComponent();
     NewRecept = null;
     IngrRefList = FullIngrList;
     foreach (Ingredient ingr in FullIngrList)
     {
         comboBoxIngr.Items.Add(ingr.Name);
     }
 }
コード例 #2
0
 public int GetTotalEnergy(Recept recept)
 {
     int Total = 0;
     foreach (ReceptSubStruct rss in recept.IngrList)
     {
         foreach (Ingredient ingr in ingredienslista)
         {
             if (ingr.Name == rss.ingrName)
             {
                 Total += ingr.Energy;
             }
         }
     }
     return Total;
 }
コード例 #3
0
 public int GetTotalFett(Recept recept)
 {
     int Total = 0;
     foreach (ReceptSubStruct rss in recept.IngrList)
     {
         foreach (Ingredient ingr in ingredienslista)
         {
             if (ingr.Name == rss.ingrName)
             {
                 Total += ingr.Fett;
             }
         }
     }
        Total = (int)(Total / recept.IngrList.Count);
     return Total;
 }
コード例 #4
0
 public void NyttReceptKlass(Recept ReceptToAdd)
 {
     receptlista.Add(ReceptToAdd);
     SparaRecept();
 }
コード例 #5
0
        //När användaren är klar, försök skapa nytt recept
        private void buttonFinish_Click(object sender, EventArgs e)
        {
            try
            {
                int portioner = Int32.Parse(TextBoxPortioner.Text);
                List<string> TagList = new List<string>();
                foreach (object obj in listBoxTaggs.Items)
                {
                    TagList.Add(obj.ToString());
                }
                for (int z = 0; z < IngrList.Count; z++)
                {
                    IngrList[z] = new ReceptSubStruct(IngrList[z].ingrName, IngrList[z].ingrNumber / portioner);
                }

                NewRecept = new Recept(TextBoxTitel.Text, TextBoxDescription.Text, IngrList, TagList, bildsökväg);
                this.Hide();

            }
            catch
            {
                MessageBox.Show("Ett eller flera värden är inte giltliga!");
            }
        }