Exemple #1
0
        private void CookbookPageButton_Click(object sender, RoutedEventArgs e)
        {
            CookbookPage1 cookbookPage1 = new CookbookPage1();

            cookbookPageButtonImageBrush.ImageSource = cookbookButtonDarkImage; // dark

            searchPageButtonImageBrush.ImageSource        = searchButtonImage;  // light
            currentRecipePageButtonImageBrush.ImageSource = currentRecipeButtonImage;
            profilePageButtonImageBrush.ImageSource       = profileButtonImage;

            Main.Content = cookbookPage1;
        }
        private void saveButton_Click(object sender, RoutedEventArgs e)
        {
            bool nameTaken = false;

            for (int i = 0; i < GlobalData.Instance.modRecipeList.Count; i++)
            {
                if (recipeMod._name == GlobalData.Instance.modRecipeList[i]._name)
                {
                    nameTaken = true;
                }
            }
            if (!nameTaken || recipeMod.modified)
            {
                //If the recipe is an original, then add it into the modified tab
                if (recipeMod.modified == false)
                {
                    //Need to add into ModList
                    recipeMod.modified = true;          //Flag as modified recipe
                    globalModRecipeList.Add(recipeMod); //Add it into the modified recipe list
                                                        //Also make an instance of a profile page for later access

                    /*
                     * bool nameInRecipe = false;
                     * for(int i = 0; i < GlobalData.Instance.recipeList.Count; i++)
                     * {
                     *  if(recipeMod._name == GlobalData.Instance.recipeList[i]._name)
                     *  {
                     *      nameInRecipe = true;
                     *  }
                     * }*/
                    //if (nameInRecipe)
                    //  recipeMod._name = "*" + recipeMod._name;

                    RecipeProfilePage modProfilePage = new RecipeProfilePage(recipeMod);
                    globalModPageList.Add(modProfilePage);
                }
                //If the recipe is modified, then the edits will just replace it
                else
                {
                    //I need to know the one i'm replacing
                    globalModRecipeList.RemoveAt(recipeNum);
                    globalModPageList.RemoveAt(recipeNum);

                    globalModRecipeList.Insert(recipeNum, recipeMod);
                    RecipeProfilePage modProfilePage = new RecipeProfilePage(recipeMod);
                    globalModPageList.Insert(recipeNum, modProfilePage);
                }

                //Need to reload previous page, just gonna be hard coded to favourite page rn...
                //Probably pass in previous page into this page. Or have "previous page" as a global data. and reload it when this button is pressed.
                //CookbookPage1 prevPage = new CookbookPage1();
                //((MainWindow)App.Current.MainWindow).Main.Content = prevPage;
                //this.NavigationService.Navigate(previousPage);
                GlobalData.Instance.currentRecipe    = null;
                GlobalData.Instance.goBackToPersonal = true;
                CookbookPage1 x = new CookbookPage1();
                ((MainWindow)App.Current.MainWindow).currentRecipePageButtonImageBrush.ImageSource = (BitmapImage)Application.Current.Resources["currentRecipeButtonIcon"];
                ((MainWindow)App.Current.MainWindow).cookbookPageButtonImageBrush.ImageSource      = (BitmapImage)Application.Current.Resources["cookbookButtonDarkIcon"];
                this.NavigationService.Navigate(x);
            }
            else
            {
                error1.Visibility = System.Windows.Visibility.Visible;
            }
        }