public MenuItem(Project1.Models.MenuItem menuItem) { this.menuItem = menuItem; InitializeComponent(); string filename = "http://localhost:11799" + menuItem.ImagePath; pictureBox1.Image = GetImageFromPicPath(filename); label1.Text = menuItem.Name; label2.Text = menuItem.Price.ToString("C"); }
private void Mi_MenuSelected(object sender, Models.MenuItem mm) { Panel pn = new Panel(); pn.Size = new Size(220, 230); MenuItem mi = new MenuItem(mm); mi.isMenuList = false; mi.RemoveFromCart += Mi_RemoveFromCart; pn.Name = "cart" + mm.Id.ToString(); pn.Controls.Add(mi); flowLayoutPanel2.Controls.Add(pn); flowLayoutPanel2.HorizontalScroll.Value = flowLayoutPanel2.HorizontalScroll.Maximum; flowLayoutPanel1.PerformLayout(); lblTotal.Text = receipt.GetTotalPrice().ToString("C"); }
private void Mi_RemoveFromCart(object sender, Models.MenuItem menuItem) { //flowLayoutPanel2.Controls.Remove(((MenuItem)flowLayoutPanel2.Controls["cart" + menuItem.Id.ToString()])); Control selectedControl = new Control(); foreach (Control control in flowLayoutPanel2.Controls) { if (control.Name == "cart" + menuItem.Id.ToString()) { selectedControl = control; break; } } if (selectedControl != null && selectedControl.Name == "cart" + menuItem.Id.ToString()) { flowLayoutPanel2.Controls.Remove(selectedControl); } lblTotal.Text = receipt.GetTotalPrice().ToString("C"); }
public void RemoveReceipt(MenuItem menuItem) { menuItems.Remove(menuItem); }
public void AddReceipt(MenuItem menuItem) { menuItems.Add(menuItem); }