예제 #1
0
        /// <summary>
        /// Returns the added Picturebox
        /// </summary>
        /// <param name="prod"></param>
        /// <param name="lane"></param>
        /// <returns></returns>
        private PictureBox AddToLane(Product prod, FlowLayoutPanel lane)
        {
            Image im = productIcons[prod];

            im = ExtraGraphics.AddTextOverlay(im, prod);
            PictureBox pb = ExtraGraphics.GeneratePictureBox(im);

            lane.Controls.Add(pb);
            return(pb);
        }
예제 #2
0
        /// <summary>
        /// Adds a product to both the graphical and logical product list.
        /// </summary>
        /// <param name="product"></param>
        private void AddItem(Product product)
        {
            List <Product> products = new List <Product>();

            //if identical items are grouped, the item has to be found, removed and readded with a higher counter
            if (isGroupingEnabled)
            {
                var toRemove = new List <PictureBox>();
                foreach (var pb in addedProducts.Keys)
                {
                    if (product.Equals(addedProducts[pb]))
                    {
                        toRemove.Add(pb);
                    }
                }
                product.Count += toRemove.Sum(x => addedProducts[x].Count);

                foreach (var pb in toRemove)
                {
                    SelectPictureBox(pb);
                    RemovePictureBox();
                }
                products.Add(product);
            }
            else
            {
                ///Adds the number of items in the product object to the logical list
                for (int i = 0; i < product.Count; i++)
                {
                    products.Add(new Product(product));
                }
            }
            /// Handles text overlay on image
            foreach (var prod in products)
            {
                Image im = GetProductImage(prod);
                im = ExtraGraphics.AddTextOverlay(im, prod);
                PictureBox pic = AddPictureBox(im);
                addedProducts.Add(pic, prod);
            }
        }