private void LoadEditRecipe(object sender, EventArgs e) { RecipeButton btn = (RecipeButton)sender; RecipeEditor editor = new RecipeEditor(_chosenBook, Controller.GetInstance().GetRecipe(_chosenBook, btn.ID)); Navigate(editor); }
private void LoadRecipe(object sender, EventArgs e) { RecipeButton senderButton = (RecipeButton)sender; RecipeViewer viewer = new RecipeViewer(_controller.GetRecipe(_chosenBook, senderButton.ID)); Navigate(viewer); }
private void LoadCurrentRecipes(object sender, EventArgs e) { RecipePanel.Children.Clear(); foreach (IRecipe recipe in _controller.GetRecipies(_chosenBook)) { Button button = new RecipeButton(recipe.ID, recipe.Title, LoadRecipe, DeleteRecipe, LoadEditRecipe); RecipePanel.Children.Add(button); } RecipeButton newButton = new RecipeButton(0, "New recipe", ShowRecipeCreator, DeleteRecipe, LoadEditRecipe); RecipePanel.Children.Add(newButton); }
private void DeleteRecipe(object sender, EventArgs e) { RecipeButton btn = (RecipeButton)sender; string msg = $"Are you sure you want to delete {btn.Content}?"; MessageBoxResult messageBoxResult = MessageBox.Show(msg, "Delete Confirmation", MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { _controller.DeleteRecipe(_chosenBook, btn.ID); ShowRecipeCreator(null, null); LoadCurrentRecipes(null, null); } }
private void LoadRecipes(object sender, EventArgs e) { RecipePanel.Children.Clear(); BookButton senderButton = (BookButton)sender; _chosenBook = senderButton.ID; // Implement getRecipes and change books to that foreach (IRecipe recipe in _controller.GetRecipies(senderButton.ID)) { Button button = new RecipeButton(recipe.ID, recipe.Title, LoadRecipe, DeleteRecipe, LoadEditRecipe); RecipePanel.Children.Add(button); } RecipeButton newButton = new RecipeButton(0, "New recipe", ShowRecipeCreator, DeleteRecipe, LoadEditRecipe); RecipePanel.Children.Add(newButton); ShowRecipeCreator(null, null); }