protected void UserControl_Click(object sender, EventArgs e) { if (this.selected != null) { this.selected.BackColor = SystemColors.Control; } this.selected = (ImageUS)sender; this.selected.BackColor = SystemColors.Highlight; }
private void buttonAdd_Click(object sender, EventArgs e) { ImageUS add = new ImageUS(this.connection, this.vehicle); add.ImageCar = new ImageCar(this.connection, this.vehicle); add.Click += new EventHandler(UserControl_Click); this.flowLayoutPanelImages.Controls.Add(add); }
private void FormImages_Load(object sender, EventArgs e) { this.groupBoxHeader.Paint += PaintBorderlessGroupBox; if (this.vehicle.Pictures.Count != 0) { ImageUS uS = null; foreach (ImageCar pic in this.vehicle.Pictures) { uS = new ImageUS(); uS.ImageCar = pic; uS.Kind = pic.Kind; uS.Main = pic.Main; uS.Picture = pic.Image; uS.Description = pic.Description; uS.Click += new EventHandler(UserControl_Click); this.flowLayoutPanelImages.Controls.Add(uS); } } else { ImageUS add = new ImageUS(this.connection, this.vehicle); add.ImageCar = new ImageCar(this.connection, this.vehicle); add.Click += new EventHandler(UserControl_Click); this.flowLayoutPanelImages.Controls.Add(add); } if (this.vehicle.CarId.HasValue) { this.groupBoxImages.Text = $"Bilder für {this.vehicle.Brand} {this.vehicle.Modell}"; } else { this.groupBoxImages.Text = $"Bilder für neues Auto"; } }