Ejemplo n.º 1
0
        public AppShell()
        {
            this.InitializeComponent();
            currentList = App.recipes;

            currentShell = appShell;
        }
Ejemplo n.º 2
0
        /*
         *  When the page is navigated to, check if we're editing an
         *  Existing recipe. If so, load that one. Otherwise, create
         *  a new recipe and use that as the context for this form.
         */
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            recipes = (RecipeList)e.Parameter;
            if (recipes.isEditing())
            {
                recipe = recipes.getSelected();
                for (int i = 0; i < recipe.RecipeIngredients.Count; i++)
                {
                    ingredients.Add(recipe.RecipeIngredients[i]);
                }

                for (int i = 0; i < recipe.RecipeImages.Count; i++)
                {
                    images.Add(recipe.RecipeImages[i]);
                }

                for (int i = 0; i < recipe.RecipeSteps.Count; i++)
                {
                    steps.Add(recipe.RecipeSteps[i]);
                }
            }
            else
            {
                // we're creating a new recipe
                recipe    = new Recipe();
                recipe.ID = RecipeList.recipeIdGenerator.getId();
            }

            if (isNarrow())
            {
                IList <PageStackEntry> backStack = Frame.BackStack;
                int backStackCount = backStack.Count;
                if (backStackCount > 0)
                {
                    PageStackEntry masterPageEntry = backStack[backStackCount - 1];
                    backStack.RemoveAt(backStackCount - 1);

                    PageStackEntry modifiedEntry = new PageStackEntry(
                        typeof(RecipeMasterDetailPage),
                        recipes,
                        masterPageEntry.NavigationTransitionInfo
                        );

                    backStack.Add(modifiedEntry);
                }
            }

            tempImageFolder = await RecipeList.tempFolder.CreateFolderAsync("" + recipe.ID, CreationCollisionOption.ReplaceExisting);

            this.imageFlipView.ItemsSource  = images;
            this.ingredientList.ItemsSource = ingredients;
            this.recipeSteps.ItemsSource    = steps;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            this.Suspending += OnSuspending;
            recipes          = new RecipeList();

            recipes.verifyImageFolder();

            RecipeBookDataAccessor.InitializeDatabase();

            long recipeStartingId = RecipeBookDataAccessor.getMaxId(Recipe.TABLE_NAME) + 1;

            RecipeList.recipeIdGenerator = new IdentifierGenerator(Recipe.TABLE_NAME, recipeStartingId);

            long ingredientStartingId = RecipeBookDataAccessor.getMaxId(RecipeIngredient.TABLE_NAME) + 1;

            RecipeList.ingredientIdGenerator = new IdentifierGenerator(RecipeIngredient.TABLE_NAME, ingredientStartingId);

            long stepStartingId = RecipeBookDataAccessor.getMaxId(RecipeStep.TABLE_NAME) + 1;

            RecipeList.stepIdGenerator = new IdentifierGenerator(RecipeStep.TABLE_NAME, stepStartingId);

            long imageStartingId = RecipeBookDataAccessor.getMaxId(RecipeImage.TABLE_NAME) + 1;

            RecipeList.imageIdGenerator = new IdentifierGenerator(RecipeImage.TABLE_NAME, imageStartingId);

            long entryStartingId = RecipeBookDataAccessor.getMaxId(RecipeJournalEntry.TABLE_NAME) + 1;

            RecipeList.journalEntryIdGenerator = new IdentifierGenerator(RecipeJournalEntry.TABLE_NAME, entryStartingId);

            ObservableCollection <Recipe> savedRecipes = RecipeBookDataAccessor.getSavedRecipes();

            for (int i = 0; i < savedRecipes.Count; i++)
            {
                Recipe savedRecipe = savedRecipes[i];
                ObservableCollection <RecipeIngredient> savedIngredients = RecipeBookDataAccessor.getIngredients(savedRecipe.ID);
                ObservableCollection <RecipeStep>       savedSteps       = RecipeBookDataAccessor.getSteps(savedRecipe.ID);
                ObservableCollection <RecipeImage>      savedImages      = RecipeBookDataAccessor.getImages(savedRecipe.ID);
                RecipeJournal savedEntries = RecipeBookDataAccessor.getJournalEntries(savedRecipe.ID);
                savedRecipe.setIngredients(savedIngredients);
                savedRecipe.setSteps(savedSteps);
                savedRecipe.setImages(savedImages);
                savedRecipe.setJournalEntries(savedEntries);
            }
            recipes.setRecipeList(savedRecipes);
        }
Ejemplo n.º 4
0
 public BrowseRecipesPage()                                                                  //When the page is opened:
 {
     InitializeComponent();
     ListOfRecipesBox.ItemsSource = RecipeList.RecipeNameList();                                 //Display a list of all the recipe names.
 }