Exemplo n.º 1
0
        /// <summary>
        /// edit ingredients to recipeObj1
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnEditIngredients_Click(object sender, EventArgs e)
        {
            FormIngredients formIngredientsObj = new FormIngredients(new Recipe(recipeObj1));  // create object
            DialogResult    dialogResult       = formIngredientsObj.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                recipeObj1 = formIngredientsObj.Recipe; // change reference to recipe object created by FormIngredients
                UpdateGuiList();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Opens up a window that let's the user edit the ingredient list for
        /// the current recipe. Changes are only saved if the user clicks ok.
        /// </summary>
        private void btnAddIngredients_Click(object sender, EventArgs e)
        {
            FormIngredients dlg       = new FormIngredients(currRecipe);
            DialogResult    dlgResult = dlg.ShowDialog();

            string[] old_ingredients = (string[])currRecipe.Ingredients.Clone();

            if (dlgResult == DialogResult.OK)
            {
                if (currRecipe.GetCurrentNumOfIngredients() <= 0)
                {
                    MessageBox.Show("No ingriedients specified!");
                }
                else
                {
                    currRecipe.Ingredients = old_ingredients;
                }
            }
        }
Exemplo n.º 3
0
        private void btnAddIngredient_Click(object sender, EventArgs e)
        // Code from assignment document
        {
            ReadInputsForCurrentRecipe();
            FormIngredients dlg          = new FormIngredients(_currentRecipe);
            DialogResult    dialogResult = dlg.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                if (_currentRecipe.CurrentNumOfIngredients <= 0)
                {
                    MessageBox.Show("No ingredients specified!");
                    // UpdateGui();  // Do this regardless of success or not.
                }
            }

            // This is not from the assignment, but it's reasonable:
            UpdateGuiLeft();
        }