示例#1
0
        // ---------------------------------------------------------------------
        // Loads the various group boxes for each item and fills them
        // with the corresponding options.
        // ---------------------------------------------------------------------
        private void load_options()
        {
            for (int i = 0; i < itemList.Count; i++)
            {
                //GroupBox(itemOptions)
                GroupBox optionBox = new GroupBox();
                optionBox.Name = "grpBox_" + itemList[i];


                //visibility and movement
                optionBox.Width    = categoryBtnBox.Width;
                optionBox.Height   = categoryBtnBox.Height;
                optionBox.Location = new Point(centerX - optionBox.Width, 0);
                itemGrpBxList.Add(optionBox);
                this.Controls.Add(optionBox);
                optionBox.Visible = false;

                List <string> options = new List <string>();
                options = orderController.getMenuItemOptions(itemList[i]);
                int x = 0;
                for (int j = 0; j < options.Count; j++)
                {
                    Point position = findPosition(optionBox);

                    string name         = "btn_" + options[j];
                    Button optionButton = (new CustomButton(name, options[j], position, Color.White, smallX, smallY)).toButton();
                    if (j == 0 && orderController.getCategoryOfMenuItem(itemList[i]).Equals("Drinks"))
                    {
                        optionButton = removePrefix(optionButton, "No");
                    }
                    else if (orderController.getCategoryOfMenuItem(itemList[i]).Equals("Drinks"))
                    {
                        optionButton.Text = "No " + optionButton.Text;
                    }
                    else
                    {
                        optionButton = removePrefix(optionButton, "No");
                    }
                    optionButton.Click += new EventHandler(CustomOption_Click);
                    optionBox.Controls.Add(optionButton);
                    if (j == 0)
                    {
                        x = optionButton.Location.X;
                    }
                }
                int row = (optionBox.Controls.Count / PER_ROW) + 1;
                if (optionBox.Controls.Count % PER_ROW == 0)
                {
                    row--;
                }
                int y = (row) * (spacingY + smallY);

                Point  posBack    = new Point(x, y);
                Button backButton = (new CustomButton("btn_back", "Back", posBack, Color.White, smallX, smallY)).toButton();
                backButton.Click += new EventHandler(CustomBack_Click);

                this.Controls.Add(backButton);
                optionBox.Controls.Add(backButton);
                Point  posAdd     = new Point(optionBox.Width - x - smallX, backButton.Location.Y);
                Button addToOrder = (new CustomButton("btn_addToOrder", "Add to Order", posAdd, Color.White, smallX, smallY)).toButton();
                addToOrder.Click += new EventHandler(CustomAddToOrder_Click);
                this.Controls.Add(addToOrder);
                optionBox.Controls.Add(addToOrder);
            }
        }
        /*
         * Loads the various group boxes for each item and fills them
         * with the corresponding options.
         */
        private void load_options()
        {
            for (int i = 0; i < itemList.Count; i++)
            {
                //GroupBox(itemOptions)
                GroupBox optionBox = new GroupBox();
                optionBox.Name     = "grpBox_" + itemList[i];
                optionBox.Location = new Point(CENTER_X, 0);

                //visibility and movement
                optionBox.Width  = categoryBtnBox.Width;
                optionBox.Height = categoryBtnBox.Height;
                itemGrpBxList.Add(optionBox);
                this.Controls.Add(optionBox);
                optionBox.Visible = false;

                List <string> options = new List <string>();
                options = orderController.getMenuItemOptions(itemList[i]);

                for (int j = 0; j < options.Count; j++)
                {
                    Button optionButton = new Button();

                    optionButton.Name = "btn_" + options[j];
                    optionButton.Text = options[j];

                    if (j == 0 && orderController.getCategoryOfMenuItem(itemList[i]).Equals("Drinks"))
                    {
                        optionButton.BackColor = Color.LightGreen;
                    }
                    else if (orderController.getCategoryOfMenuItem(itemList[i]).Equals("Drinks"))
                    {
                        optionButton.BackColor = Color.Red;
                    }
                    else
                    {
                        optionButton.BackColor = Color.LightGreen;
                    }

                    optionButton.FlatStyle = FlatStyle.Popup;
                    optionButton.Width     = smallX;
                    optionButton.Height    = smallY;
                    optionButton.Click    += new EventHandler(CustomOption_Click);
                    this.Controls.Add(optionButton);
                    optionButton.Location = findPosition(optionBox);
                    optionBox.Controls.Add(optionButton);
                }
                Button backButton = (new CustomButton("btn_back", "Back", findPosition(optionBox), Color.White, smallX, smallY)).toButton();
                backButton.Click += new EventHandler(CustomBack_Click);

                this.Controls.Add(backButton);
                // backButton.Location = new Point(25, optionBox.Height - optionBox.Location.Y);
                optionBox.Controls.Add(backButton);

                addToOrder           = new Button();
                addToOrder.Name      = "btn_addToOrder";
                addToOrder.Text      = "Add To Order";
                addToOrder.BackColor = Color.White;
                addToOrder.FlatStyle = FlatStyle.Popup;
                addToOrder.Width     = smallX;
                addToOrder.Height    = smallY;
                addToOrder.Click    += new EventHandler(CustomAddToOrder_Click);

                this.Controls.Add(addToOrder);
                addToOrder.Location = new Point(optionBox.Width - smallX - SPACING_X, backButton.Location.Y);
                optionBox.Controls.Add(addToOrder);
            }
        }