Пример #1
0
        private void add_New_Recipe_Click(object sender, RoutedEventArgs e)
        {
            // Give the user another window for adding a new recipe
            EnterNewRecipeMenu enterNewRecipeMenu = new EnterNewRecipeMenu();

            enterNewRecipeMenu.Owner = this;
            enterNewRecipeMenu.WindowStartupLocation = WindowStartupLocation.Manual;
            enterNewRecipeMenu.Top  = this.Top + 150;
            enterNewRecipeMenu.Left = this.Left + 300;
            enterNewRecipeMenu.ShowDialog();
        }
Пример #2
0
        private void EditRecipe_Button_Click(object sender, RoutedEventArgs e)
        {
            if (!(SelectRecipes_ListBox.SelectedItem == null))
            {
                // This makes a copy of the NewRecipeMenu and uses it to edit a recipe instead, allowing the user to change a current selected recipe it
                // uses info from the card viewer
                EnterNewRecipeMenu enterEditRecipeMenu = new EnterNewRecipeMenu();
                enterEditRecipeMenu.Owner = this;
                enterEditRecipeMenu.WindowStartupLocation = WindowStartupLocation.Manual;
                enterEditRecipeMenu.Top  = this.Top + 150;
                enterEditRecipeMenu.Left = this.Left + 300;

                enterEditRecipeMenu.IsThisAnEdit  = true;
                enterEditRecipeMenu.OldRecipePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Recipe Rack\\Recipes\\" + Card_RecipeName_Label.Content.ToString().Trim() + ".json";


                enterEditRecipeMenu.Directions_RichTextBox.AppendText((new TextRange(Card_RecipeBody_RichTextBox.Document.ContentStart, Card_RecipeBody_RichTextBox.Document.ContentEnd).Text));
                enterEditRecipeMenu.RecipeName_TextBox.Text = Card_RecipeName_Label.Content.ToString();
                enterEditRecipeMenu.RecipeDifficulty_ComboBox.SelectedItem = Card_RecipeDifficulty_Label.Content;
                enterEditRecipeMenu.RecipeCategory_ComboBox.SelectedItem   = Card_RecipeCategory_Label.Content;

                if (Card_IsFavoriteStar_Image.Visibility == Visibility.Visible)
                {
                    enterEditRecipeMenu.IsFavorite_Checkbox.IsChecked = true;
                }



                // add items from list to the new edit box

                foreach (var item in Card_RecipeIngredients_ListBox.Items)
                {
                    // This checks for empty whitespaces and deletes them so there are not any blank ingredient items in the list.
                    if (item.ToString().Length < 4)
                    {
                        enterEditRecipeMenu.EnterNewRecipe_IngredientListView.Items.Remove(item);
                    }
                    enterEditRecipeMenu.EnterNewRecipe_IngredientListView.Items.Add(item);
                }
                // remove the trailing whitespace
                enterEditRecipeMenu.EnterNewRecipe_IngredientListView.Items.RemoveAt(enterEditRecipeMenu.EnterNewRecipe_IngredientListView.Items.Count - 1);

                // This is here so when the dialog box is closed the SelectRecipeNames list doesnt loop out of index *Bug avoidance*
                SelectRecipes_ListBox.Items.Clear();

                enterEditRecipeMenu.ShowDialog();
            }
        }