Example #1
0
        private void AddProduct(Product product)
        {
            ProductPanel productPanel = new ProductPanel();

            productPanel.Product   = product;
            productPanel.Name      = "ProductPanel" + product.ID.ToString();
            productPanel.ClickBuy += ClickProductBuy;

            Controls.Add(productPanel);
        }
Example #2
0
        public void Populate(List <ProductPanel> productPanels)
        {
            for (var index = 0; index < productPanels.Count(); index++)
            {
                ProductPanel productPanel = productPanels[index];

                if (index != 0)
                {
                    ProductPanel lastProductPanel = productPanels[index - 1];

                    int x = index % NumberOfColumns == 0 ? 0 : lastProductPanel.Location.X + productPanel.Width + productPanel.Margin.Horizontal;
                    int y = index % NumberOfColumns == 0 ? lastProductPanel.Location.Y + productPanel.Height + productPanel.Margin.Vertical : lastProductPanel.Location.Y;

                    productPanel.Location = new System.Drawing.Point(x, y);
                }
                else
                {
                    productPanel.Location = new System.Drawing.Point(0, 0);
                }

                Controls.Add(productPanel);
            }
        }