Esempio n. 1
0
        /// <summary> method: btnAdd_Click_1
        /// adds item to the model based on existing parameters picked by the user
        /// </summary>

        private void btnAdd_Click_1(object sender, EventArgs e)
        {
            AnyItem anItem;

            try
            {
                // if fruits is selected create the circle shape
                if (rbFruits.Checked)
                {
                    anItem = new Produce("Fruits", 0, 0, 50, 50, Color.Orange);
                    model.AddItem(anItem);
                }

                //if vegetables is selected create the circle shape
                else if (rbVege.Checked)
                {
                    anItem = new Produce("Vegetables", 0, 60, 50, 50, Color.Green);
                    model.AddItem(anItem);
                }

                // if chicken is selected create the rectangle shape
                else if (rbChicken.Checked)
                {
                    anItem = new Meat("Chicken", 120, 0, 60, 50, Color.Pink);
                    model.AddItem(anItem);
                }

                // if beef is selected create the rectangle shape
                else if (rbBeef.Checked)
                {
                    anItem = new Meat("Beef", 120, 80, 60, 50, Color.Red);
                    model.AddItem(anItem);
                }

                // if pork is selected create the rectangle shape
                else if (rbPork.Checked)
                {
                    anItem = new Meat("Pork", 120, 180, 60, 50, Color.Blue);
                    model.AddItem(anItem);
                }

                // if fish is selected create the rectangle shape
                else if (rbFish.Checked)
                {
                    anItem = new Meat("Fish", 120, 260, 60, 50, Color.Yellow);
                    model.AddItem(anItem);
                }

                // if shampoo is selected create the triangle shape
                else if (rbShampoo.Checked)
                {
                    anItem = new PersonalCare("Shampoo", 250, 0, 60, 50, Color.Magenta);
                    model.AddItem(anItem);
                }

                // if soap is selected create the triangle shape
                else if (rbSoap.Checked)
                {
                    anItem = new PersonalCare("Soap", 250, 60, 60, 50, Color.Lavender);
                    model.AddItem(anItem);
                }

                // if hand soap is selected create the triangle shape
                else if (rbHand.Checked)
                {
                    anItem = new PersonalCare("Hand Soap", 250, 120, 60, 50, Color.LightBlue);
                    model.AddItem(anItem);
                }

                //else // must be an ellipse
                //{
                //     anItem = new AnyElipse("elipse", X, Y, Width, Height, aColor);
                //     model.AddItem(anItem);
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\n" + "\r\n" + ex.ToString(),
                                "Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary> method: btnAdd_Click
        /// adds item to the model based on existing parameters picked by the user
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void btnAdd_Click_1(object sender, EventArgs e)
        {
            AnyItem anItem;

            // if fruits is selected create the circle shape
            if (rbFruits.Checked)
            {
                anItem = new Produce("Fruits", 0, 0, 50, 50, Color.Orange);
                model.AddItem(anItem);
            }

            //if vegetables is selected create the circle shape
            else if (rbVege.Checked)
            {
                anItem = new Produce("Vegetables", 0, 60, 50, 50, Color.Green);
                model.AddItem(anItem);
            }

            // if chicken is selected create the square shape
            else if (rbChicken.Checked)
            {
                anItem = new Meat("Chicken", 120, 0, 50, 50, Color.Pink);
                model.AddItem(anItem);
            }

            // if beef is selected create the rectangle shape
            else if (rbBeef.Checked)
            {
                anItem = new Meat("Beef", 120, 60, 60, 50, Color.Red);
                model.AddItem(anItem);
            }

            // if pork is selected create the rectangle shape
            else if (rbPork.Checked)
            {
                anItem = new Meat("Pork", 120, 120, 60, 50, Color.Blue);
                model.AddItem(anItem);
            }

            // if fish is selected create the rectangle shape
            else if (rbFish.Checked)
            {
                anItem = new Meat("Fish", 120, 190, 60, 50, Color.Yellow);
                model.AddItem(anItem);
            }

            // if shampoo is selected create the triangle shape
            else if (rbShampoo.Checked)
            {
                anItem = new PersonalCare("Shampoo", 250, 0, 60, 50, Color.Magenta);
                model.AddItem(anItem);
            }

            // if soap is selected create the triangle shape
            else if (rbSoap.Checked)
            {
                anItem = new PersonalCare("Soap", 250, 60, 60, 50, Color.Lavender);
                model.AddItem(anItem);
            }

            // if hand soap is selected create the triangle shape
            else if (rbHand.Checked)
            {
                anItem = new PersonalCare("Hand Soap", 250, 120, 60, 50, Color.LightBlue);
                model.AddItem(anItem);
            }

            //else // must be an ellipse
            //{
            //     anItem = new AnyElipse("elipse", X, Y, Width, Height, aColor);
            //     model.AddItem(anItem);
            //}
        }