// public PlacementController(MainFrame motherFrame, ProductAdding pa) { this.motherFrame = motherFrame; productAdding = pa; clickLocation = new Point(0, 0); productAdding.productPanel.knowYourController(this); //Make an event when the selection of the ASSORTMENT or INVENTORY has changed productAdding.productList1.SelectionChanged += new ProductSelectionChanged(this.ChangeSelected); //Select the first product from the product list, and display it in the default info try { ProductInfo defaultInfo = new ProductInfo(ProductModel.List[0]); ChangeSelected(defaultInfo); } catch { } //Make an event that triggers when the list is changed, so that it automatically repaints the screen. placedProductList.CollectionChanged += ppList_CollectionChanged; //TEMP //Fill the staticlyplaced list with walls Vector pointTopLeft = new Vector(0, 0); Vector pointTopRight = new Vector(productAdding.productPanel.Width - 1, 0); Vector pointBottomLeft = new Vector(0, productAdding.productPanel.Height - 1); Vector pointBottomRight = new Vector(productAdding.productPanel.Width - 1, productAdding.productPanel.Height - 1); staticlyPlacedObjectList = new List<PlacedProduct>(); int length = (int)(pointBottomRight.Y - pointTopRight.Y); int width = (int)(pointTopRight.X - pointTopLeft.X); staticlyPlacedObjectList.Add( //Top new PlacedProduct( new ProductModel(0, "", "", width, 1, 1, true), new PointF(width / 2, 0))); staticlyPlacedObjectList.Add( //Right new PlacedProduct( new ProductModel(0, "", "", 1, 1, length, true), new PointF(width, length / 2))); staticlyPlacedObjectList.Add( //Bottom new PlacedProduct( new ProductModel(0, "", "", width, 1, 1, true), new PointF(width / 2, length))); staticlyPlacedObjectList.Add( //Left new PlacedProduct( new ProductModel(0, "", "", 1, 1, length, true), new PointF(0, length / 2))); }
private void GenerateProducts() { //remove all ProductInfos RemoveItems(); //Make generate all the products currently in the list, to display them to the user int y = 0; if (!_locked) { foreach (ProductModel product in ProductModel.StaticList) { ProductInfo pi = new ProductInfo(product); pi.Location = new Point(0, y); pi.MouseClick += new MouseEventHandler(product_Selected); //The event pi.pbx_Image.MouseDown += new MouseEventHandler(product_Selected); //The event this.Controls.Add(pi); listOfInformation.Add(pi); y += pi.Height; } } else if (_locked) { var onlyAvailibleProducts = from products in ProductModel.List where products.Removed == false select products; foreach (ProductModel product in onlyAvailibleProducts) { ProductInfo pi = new ProductInfo(product); pi.Location = new Point(0, y); pi.MouseClick += new MouseEventHandler(product_Selected); //The event pi.pbx_Image.MouseDown += new MouseEventHandler(product_Selected); //The event this.Controls.Add(pi); listOfInformation.Add(pi); y += pi.Height; } } fixInformation(); }
// public void ChangeSelected(ProductInfo sender) { productAdding.productInfo1.setProduct(sender.product); //Sets a new product if(currentProduct.Product.Name != sender.product.Name) { currentProduct = null; } //Seing as name is an identifier in the database, this can be used to compare the two: Look if the names are the same, if not, then a different product is the currentProduct. Therefore the currentProduct needs to be set to null. }