private void splitContainer1_Panel2_MouseClick(object sender, MouseEventArgs e) { if (!IsLinking) { this.splitContainer1.Panel1.Enabled = true; if (this.listBox1.SelectedIndex != -1) { string classToInstanciate = this.listBox1.GetItemText(this.listBox1.SelectedItem); try { switch (classToInstanciate) { case "Arrivée Manuelle": ArriveeManuelle arrivemanuelle = new ArriveeManuelle(); this.splitContainer1.Panel2.Controls.Add(arrivemanuelle); arrivemanuelle.Position = arrivemanuelle.Location = new Point(e.Location.X - (arrivemanuelle.Width / 2), e.Location.Y - (arrivemanuelle.Height / 2)); this.listBox1.SelectedIndex = -1; _elements.Add(arrivemanuelle); break; case "Arrivée Prédéfinie": ArriveePredefinie arriveepredefinie = new ArriveePredefinie(); this.splitContainer1.Panel2.Controls.Add(arriveepredefinie); arriveepredefinie.Position = arriveepredefinie.Location = new Point(e.Location.X - (arriveepredefinie.Width / 2), e.Location.Y - (arriveepredefinie.Height / 2)); this.listBox1.SelectedIndex = -1; _elements.Add(arriveepredefinie); break; case "Machine": Machine machine = new Machine(); this.splitContainer1.Panel2.Controls.Add(machine); machine.Position = machine.Location = new Point(e.Location.X - (machine.Width / 2), e.Location.Y - (machine.Height / 2)); this.listBox1.SelectedIndex = -1; _elements.Add(machine); break; case "Match": Match match = new Match(); this.splitContainer1.Panel2.Controls.Add(match); match.Position = match.Location = new Point(e.Location.X - (match.Width / 2), e.Location.Y - (match.Height / 2)); this.listBox1.SelectedIndex = -1; _elements.Add(match); break; case "Batch": Batch batch = new Batch(); this.splitContainer1.Panel2.Controls.Add(batch); batch.Position = batch.Location = new Point(e.Location.X - (batch.Width / 2), e.Location.Y - (batch.Height / 2)); this.listBox1.SelectedIndex = -1; _elements.Add(batch); break; case "Unbatch": Unbatch unbatch = new Unbatch(); this.splitContainer1.Panel2.Controls.Add(unbatch); unbatch.Position = unbatch.Location = new Point(e.Location.X - (unbatch.Width / 2), e.Location.Y - (unbatch.Height / 2)); this.listBox1.SelectedIndex = -1; _elements.Add(unbatch); break; case "Router": Router router = new Router(); this.splitContainer1.Panel2.Controls.Add(router); router.Position = router.Location = new Point(e.Location.X - (router.Width / 2), e.Location.Y - (router.Height / 2)); this.listBox1.SelectedIndex = -1; _elements.Add(router); break; case "Mux": Mux mux = new Mux(); this.splitContainer1.Panel2.Controls.Add(mux); mux.Position = mux.Location = new Point(e.Location.X - (mux.Width / 2), e.Location.Y - (mux.Height / 2)); this.listBox1.SelectedIndex = -1; _elements.Add(mux); break; case "Merge": Merge merge = new Merge(); this.splitContainer1.Panel2.Controls.Add(merge); merge.Position = merge.Location = new Point(e.Location.X - (merge.Width / 2), e.Location.Y - (merge.Height / 2)); this.listBox1.SelectedIndex = -1; _elements.Add(merge); break; case "Feu": Feu feu = new Feu(); this.splitContainer1.Panel2.Controls.Add(feu); feu.Position = feu.Location = new Point(e.Location.X - (feu.Width / 2), e.Location.Y - (feu.Height / 2)); this.listBox1.SelectedIndex = -1; _elements.Add(feu); break; case "WTEG": WTEG wteg = new WTEG(); this.splitContainer1.Panel2.Controls.Add(wteg); wteg.Position = wteg.Location = new Point(e.Location.X - (wteg.Width / 2), e.Location.Y - (wteg.Height / 2)); this.listBox1.SelectedIndex = -1; _elements.Add(wteg); break; case "Convoyeur": Convoyeur convoyeur = new Convoyeur(); this.splitContainer1.Panel2.Controls.Add(convoyeur); convoyeur.Position = convoyeur.Location = new Point(e.Location.X - (convoyeur.Width / 2), e.Location.Y - (convoyeur.Height / 2)); this.listBox1.SelectedIndex = -1; _elements.Add(convoyeur); break; default: break; } } catch (Exception ex) { Console.WriteLine(ex.Message); } } } }