/// <summary> /// This method loads all pizzas in the listview /// </summary> private void cargarListViewPizzas() { List <Pizza> listaPizzas = cp.listarPizzas(); foreach (Pizza p in listaPizzas) { ListViewPizzas.Items.Add(p.getNombre()); } }
/// <summary> /// Este metodo carga las imagenes de las pizzas de forma dinamica y genera un picture box de cada una. /// La imagen la recoge de el servidor de provenapps.cat /// </summary> private void loadPizzas() { listaPizzas = cp.listarPizzas(); int j = 0; int x = 0; int x1 = 0; int y = 0; int xLabel = 0; int yLabel = 137; if (listaPizzas != null) { for (int i = 0; i < listaPizzas.Count; i++) { String pathimg = listaPizzas[i].getImagen(); PictureBox pb = new PictureBox(); pb.Name = listaPizzas[i].getNombre(); pb.Width = 141; pb.Height = 133; pb.ImageLocation = "http://provenapps.cat/~dam1804/Images/pizzas/" + pathimg; pb.BorderStyle = BorderStyle.FixedSingle; pb.BackColor = Color.White; pb.Click += new System.EventHandler(this.pressedPizza); if (i % 5 == 0 && i != 0) { y += 169; yLabel += 169; j = 0; } x1 = x + (j * 170); pb.Location = new Point(x1, y); listaPictureBoxPizzas.Add(pb); Label lb = new Label(); lb.Text = listaPizzas[i].getNombre(); lb.Location = new Point(x1, yLabel); panelPizzas.Controls.Add(pb); panelPizzas.Controls.Add(lb); j++; } } else { MessageBox.Show("Se perdiĆ³ la conexion con el servicio"); } }