private GroupBox LoadProduct(Handbag handbag, int xCoord, int yCoord, int boxSize, int handbagNo) { //Product Image GroupBox groupBox = new GroupBox(); PictureBox pictureBox = new PictureBox(); pictureBox.Load(handbag.ProductImage); pictureBox.Size = new Size(200, 200); pictureBox.SizeMode = PictureBoxSizeMode.Zoom; groupBox.Location = new Point(xCoord, yCoord); groupBox.Size = new Size(boxSize, boxSize); groupBox.Name = "handbagNo-" + handbagNo; groupBox.Controls.Add(pictureBox); groupBox.Click += clickEvent; //Product Name var image = pictureBox.Image; var font = new Font("Microsoft Sans Serif", 30, FontStyle.Regular, GraphicsUnit.Pixel); var graphics = Graphics.FromImage(image); graphics.DrawString(handbag.ProductName, font, Brushes.Black, new Point(10, 10)); pictureBox.Image = image; pictureBox.Click += clickEvent; return(groupBox); }
private void UpdatePanel(string panelName, Handbag handbag, int xCoord, int yCoord, int boxSize, int handbagNo) { this.Controls[panelName].Controls.Add(LoadProduct(handbag, xCoord, yCoord, boxSize, handbagNo)); }