public PanelProduct CreatePanel(Product product) { PanelProduct panel = null; if (product is Book) { panel = new BookPanel((Book)product); } else if (product is Magazine) { panel = new MagazinePanel((Magazine)product); } else { panel = new MusicCdPanel((MusicCD)product); } return(panel); }
private void cmbCategory_SelectedIndexChanged(object sender, EventArgs e) { flpnlItems.Controls.Clear(); CurrentProductList.Clear(); foreach (var item in (List <Product>)productList[cmbProduct.SelectedIndex]) { if (item.Category == cmbCategory.SelectedItem.ToString()) { CurrentProductList.Add(item); PanelProduct pnl = panelCreator.CreatePanel(item); flpnlItems.Controls.Add(pnl); } else if (cmbCategory.SelectedItem.ToString() == "Hepsi") { CurrentProductList.Add(item); PanelProduct pnl = panelCreator.CreatePanel(item); flpnlItems.Controls.Add(pnl); } } }