public NyttReceptForm(ref List<Ingredient> FullIngrList) { InitializeComponent(); NewRecept = null; IngrRefList = FullIngrList; foreach (Ingredient ingr in FullIngrList) { comboBoxIngr.Items.Add(ingr.Name); } }
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; }
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; }
public void NyttReceptKlass(Recept ReceptToAdd) { receptlista.Add(ReceptToAdd); SparaRecept(); }
//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!"); } }