public ShowRecipe(Classes.Recipe recipe) { InitializeComponent(); lblCategory.Text = "Kategori: " + recipe.Category; lblTitle.Text = recipe.Title; txtDescription.Text = recipe.Description; lstIngredients.Items.Clear(); foreach (KeyValuePair <string, string> kvp in recipe.IngredientsByAmount) { lstIngredients.Items.Add(kvp.Value + " - " + kvp.Key); } }
private void lstRecipe_MouseDoubleClick(object sender, MouseEventArgs e) { try { //matchar recept titel i listboxen mot rätt titel i listan samt skickar till ShowRecipie formuläret. //kommer att generera fel om två recept med samma titel läggs till if (lstRecipe.SelectedItem != null) { Classes.Recipe chosenrecipe = (Classes.Recipe)recipes.Where(recepie => recepie.Title == lstRecipe.SelectedItem.ToString()).SingleOrDefault(); ShowRecipe showRecipie = new ShowRecipe(chosenrecipe); showRecipie.Show(); } } catch (Exception exception) { ExceptionHelper exceptionhelper = new ExceptionHelper(); exceptionhelper.WriteToLogFile(exception); } }