private void menuButtonCategory_Click(object sender, EventArgs e) { menuButton b = sender as menuButton; clickedButton = b.getName; addCategoryContentToPanel(panelMenu); }
private void BackToCategory_Click(object sender, EventArgs e) { menuButton b = sender as menuButton; this.panelMenu.Controls.Remove(b); addCategoriesToPanel(this.panelMenu); }
public void addCategoryContentToPanel(Panel panel) { this.panelMenu = panel; panel.Controls.OfType <menuButton>().Where(i => i.Tag == "CATEGORY").ToList().ForEach(i => panel.Controls.Remove(i)); menuButton backToCategory = new menuButton("COFNIJ DO WYBORU KATEGORII"); Image back = Image.FromFile(@"../../back_image.png"); Point position = new Point(5, 0); this.getListOfMenuContentButtons(); foreach (menuButton button in buttons) { button.Location = position; button.Tag = "PRODUCT"; panel.Controls.Add(button); position.X += 85; if (position.X > 515) { position.Y += 85; position.X = 5; } } position.X = 0; position.Y = 520; backToCategory.Image = back; backToCategory.Location = position; backToCategory.Tag = "PRODUCT"; backToCategory.Click += BackToCategory_Click; panel.Controls.Add(backToCategory); }
private void menuButtonProduct_Click(object sender, EventArgs e) { menuButton b = sender as menuButton; order.addNewProduct(b.getProduct); this.panelOrder.Controls.Find("totalAmountOfOrder", false).Last().Text = "SUMA: " + Convert.ToString(order.getCostOfOrder) + " PLN"; updateTreeView(b.getName, b.getPrice, b.getIngredients); addCategoriesToPanel(this.panelMenu); }
private void InputButton_Selected(object sender, EventArgs e) { menuButton b = sender as menuButton; if (b.getColor != Color.OrangeRed) { input.getIngredients.Remove(input.getIngredients.Find(x => x.ToUpper() == b.getName)); b.getColor = Color.OrangeRed; } else { input.getIngredients.Add(b.getName); b.getColor = Color.LightYellow; } }
private void OutputButton_Selected(object sender, EventArgs e) { menuButton b = sender as menuButton; if (b.getColor != Color.Green) { input.getIngredients.Add(b.getName); input.getPrice = Convert.ToString(Convert.ToDouble(input.getPrice) + Convert.ToDouble(b.getPrice)); b.getColor = Color.Green; } else { input.getIngredients.Remove(b.getName); input.getPrice = Convert.ToString(Convert.ToDouble(input.getPrice) - Convert.ToDouble(b.getPrice)); b.getColor = Color.LightYellow; } }
private void ChangeIngredient_Load(object sender, EventArgs e) { #region DODAWANIE PRZYCISKÓW AKTUALNYCH SKŁADNIKÓW PIZZY Point position = new Point(0, 0); foreach (string item in input.getIngredients) { menuButton button = new menuButton(item.ToUpper()); button.Location = position; button.Click += InputButton_Selected; position.X += 85; panel1.Controls.Add(button); } #endregion #region DODAWANIE PRZYCISKÓW WSZYSTKICH DOSTEPNYCH SKŁADNIKÓW PIZZY int size = 0; string price = ""; if (input.getName.Contains("32")) { size = 32; } else if (input.getName.Contains("43")) { size = 43; } position = new Point(0, 0); Color color = Color.White; ingredients = fs.getFileContent(); foreach (string item in ingredients) { if (item.Contains("Color.") == true) { string tmpStr = item.Remove(0, 6); color = Color.FromName(tmpStr); } else if (item.Contains("32") || item.Contains("43")) { if (item.Contains(Convert.ToString(size))) { string tmpStr = item.Remove(0, 3); price = tmpStr; } } else { menuButton button = new menuButton(item); button.getColor = color; button.getPrice = price; button.Location = position; button.Click += OutputButton_Selected; position.X += 85; if (position.X > 800) { position.Y += 85; position.X = 0; } panel2.Controls.Add(button); } } position = new Point(0, 0); #endregion }