public void cancelConfig(object sender, EventArgs e) { Button button = (Button)sender; if (button.Name.Substring(0, 5).Equals("CancG")) { int i = int.Parse(button.Name.Replace("CancG", "")); PanelEx p = container.allPanelGames.ElementAt(i); ProgramConfiguration pg = container.ListConfigGames.ElementAt(i); if (p.getlblAlias().Equals(pg.getAlias())) { container.ListConfigGames.Remove(pg); } container.p2.Controls.Remove(p.dynPanel); container.allPanelGames.Remove(p); container.updateNames(1, button); } if (button.Name.Substring(0, 5).Equals("CancS")) { int i = int.Parse(button.Name.Replace("CancS", "")); PanelEx p = container.allPanel.ElementAt(i); ProgramConfiguration pg = container.ListConfig.ElementAt(i); if (p.getlblAlias().Equals(pg.getAlias())) { container.ListConfig.Remove(pg); } container.p1.Controls.Remove(p.dynPanel); container.allPanel.Remove(p); container.updateNames(0, button); } }
//METODI PER LETTURA, SOVRASCRITTURA, MODIFICA DELLE CONFIGURAZIONI #region Configurations //IMPORTAZIONE AUTOMATICA ALL'AVVIO private void addFromFile() { //CREA OGGETTI E ASSEGNA LE LORO PROPRIETÀ string file = ""; String path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); if (System.IO.File.Exists(System.IO.Path.Combine(path, "MouseMapper/application.config")) || System.IO.File.ReadAllText(System.IO.Path.Combine(path, "MouseMapper")).Equals("")) { file = System.IO.File.ReadAllText(System.IO.Path.Combine(path, "MouseMapper/application.config")); } else { System.IO.Directory.CreateDirectory(Environment.SpecialFolder.MyDocuments + "MouseMapper"); System.IO.File.Create(System.IO.Path.Combine(path, "MouseMapper/application.config")); } if (!file.Equals("")) { string[] allprop; allprop = file.Split('#'); container.conta = allprop.Length - 2; for (int i = 0; i < container.conta; i++) { ProgramConfiguration pg1 = new ProgramConfiguration(allprop[i + 1]); if (pg1.getGameMode() == 0) { PanelEx dpex = new PanelEx(container.contasoftware); //CREAZIONE DI UN LABEL AGGIUNTIVO dpex.addLabel(pg1.getAlias()); //CREAZIONE DI UNA PICTUREBOX dpex.addPBox(Resources.notSet); //CREAZIONE DELLE TEXTBOX dpex.addTbox(pg1.getLeft(), pg1.getRight(), pg1.getXb2(), pg1.getXb1(), pg1.getMiddle()); //CREAZIONE DEI LABEL dpex.addTLbl(); //AGGIUNGO LISTENER dpex.addButtons(cancelConfig, modifyConfig, ("CancS" + container.contasoftware.ToString()), ("ModS" + container.contasoftware.ToString())); //AGGIUNGO DIR PER CHANGEALIAS (E DIR) dpex.setDir(pg1.getDir()); container.p1.Controls.Add(dpex.dynPanel); container.allPanel.Add(dpex); container.ListConfig.Add(pg1); container.AllConfig.Add(pg1); container.addtoList(dpex.Cancelbtn); container.contasoftware++; if (container.contasoftware * (dpex.dynPanel.Height) > container.p1.Height) { container.b1.Maximum = ((container.contasoftware * (dpex.dynPanel.Height + 5)) - container.p1.Height + 58 + 29); } } else { PanelEx dpex = new PanelEx(container.contagames); //CREAZIONE DI UN LABEL AGGIUNTIVO dpex.addLabel(pg1.getAlias()); //CREAZIONE DI UNA PICTUREBOX dpex.addPBox(Resources.notSet); //CREAZIONE DELLE TEXTBOX dpex.addTbox(pg1.getLeft(), pg1.getRight(), pg1.getXb2(), pg1.getXb1(), pg1.getMiddle()); //CREAZIONE DEI LABEL dpex.addTLbl(); //AGGIUNGO LISTENER dpex.addButtons(cancelConfig, modifyConfig, ("CancG" + container.contagames.ToString()), ("ModG" + container.contagames.ToString())); //AGGIUNGO DIR PER CHANGEALIAS (E DIR) dpex.setDir(pg1.getDir()); container.p2.Controls.Add(dpex.dynPanel); container.allPanelGames.Add(dpex); container.ListConfigGames.Add(pg1); container.AllConfig.Add(pg1); container.addtoListGames(dpex.Cancelbtn); container.contagames++; if (container.contagames * (dpex.dynPanel.Height) > container.p2.Height) { container.b2.Maximum = ((container.contagames * (dpex.dynPanel.Height + 5)) - container.p2.Height + 58 + 29); } } } container.setPBox(); } container.checkIfEmpty(); }