Ejemplo n.º 1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            int numRecipes = currentList.getRecipeList().Count;

            if (numRecipes > 0)
            {
                currentList.setSelected(0);
            }

            mainContent.Navigate(typeof(RecipeMasterDetailPage), currentList);
            appShell.SelectedItem = appShell.MenuItems[1];
        }
Ejemplo n.º 2
0
        /*
         * Save the changes made to an existing recipe or add the new
         * recipe to the recipe list.
         */
        private async void saveRecipe(object sender, RoutedEventArgs e)
        {
            String newRecipeName = this.recipeName.Text;

            // double newRecipeRating = this.recipeRating.Value;

            recipe.Name = newRecipeName;
            // recipe.Rating = newRecipeRating;
            recipe.setImages(images);
            recipe.setIngredients(ingredients);
            recipe.setSteps(steps);

            if (!recipes.isEditing())
            {
                recipes.addRecipe(recipe);
                recipes.SelectedIndex = recipes.getRecipeList().Count - 1;
            }
            else
            {
                recipes.setEditing(false);
                RecipeBookDataAccessor.updateRecipe(recipe);
            }

            for (int i = 0; i < removedSteps.Count; i++)
            {
                RecipeBookDataAccessor.deleteStep(removedSteps[i]);
            }
            for (int i = 0; i < removedIngredients.Count; i++)
            {
                RecipeBookDataAccessor.deleteIngredient(removedIngredients[i]);
            }
            for (int i = 0; i < removedImages.Count; i++)
            {
                RecipeImage imageToRemove = removedImages[i];
                StorageFile imageFile     = await StorageFile.GetFileFromPathAsync(imageToRemove.getImagePath());

                await imageFile.DeleteAsync();

                RecipeBookDataAccessor.deleteImage(imageToRemove);
            }
            Frame.GoBack();
        }