Example #1
0
        private void BtnEditProduct_Click(object sender, EventArgs e)
        {
            Product        product = srcProduct.Current as Product;
            EditIngredient editor  = new EditIngredient(
                CategoryList,
                activeBook.Images,
                product.Recipes)
            {
                CreationMode   = false,
                IngredientName = product.Name,
                Category       = product.Category,
                ImageName      = product.ImageName,
                Notes          = product.Notes,
            };

            if (editor.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            Assert(ReferenceEquals(product, srcProduct.Current));

            product.Category  = editor.Category;
            product.ImageName = editor.ImageName;
            product.Notes     = editor.Notes;

            Program.ApplicationContext.BookChanged |= editor.RecipesChanged;
        }
Example #2
0
        private void BtnEditIngredient_Click(object sender, EventArgs e)
        {
            BasicIngredient ingredient = srcBaseIngredients.Current as BasicIngredient;
            EditIngredient  editor     = new EditIngredient(
                CategoryList,
                activeBook.Images)
            {
                CreationMode   = false,
                IngredientName = ingredient.Name,
                Category       = ingredient.Category,
                ImageName      = ingredient.ImageName,
                Notes          = ingredient.Notes,
            };

            if (editor.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            Assert(ReferenceEquals(ingredient, srcBaseIngredients.Current));

            ingredient.Category  = editor.Category.Equals(Category.Anything.Name, StringComparison.Ordinal) ? null : editor.Category;
            ingredient.ImageName = editor.ImageName;
            ingredient.Notes     = editor.Notes;

            srcBaseIngredients.ResetCurrentItem();
        }
Example #3
0
        private void BtnAddProduct_Click(object sender, EventArgs e)
        {
            ObservableCollection <IngredientCollection> recipes = new ObservableCollection <IngredientCollection>();
            EditIngredient editor = new EditIngredient(
                CategoryList,
                activeBook.Images,
                recipes);

            if (editor.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            Product product = new Product(editor.IngredientName)
            {
                Category  = editor.Category,
                ImageName = editor.ImageName,
                Notes     = editor.Notes,
            };

            foreach (IngredientCollection recipe in recipes)
            {
                product.Recipes.Add(recipe);
            }

            srcProduct.Add(product);
        }
Example #4
0
        private void BtnAddIngredient_Click(object sender, EventArgs e)
        {
            EditIngredient editor = new EditIngredient(
                CategoryList,
                activeBook.Images);

            if (editor.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            srcBaseIngredients.Add(new BasicIngredient(editor.IngredientName)
            {
                Category  = editor.Category,
                ImageName = editor.ImageName,
                Notes     = editor.Notes,
            });
        }