Exemple #1
0
        //EVENTI DEDICATI A SUBFORM adder
        private void subAddbtn_Click(object sender, EventArgs e)
        {
            if (is_customizating == false)
            {
                if (!container.adder.getDirfromTxt().Equals(""))
                {
                    ProgramConfiguration pg = new ProgramConfiguration();
                    container.adder.setAlias(container.adder.getAliasfromTxt());
                    container.adder.setDir(container.adder.getDirfromTxt());
                    container.adder.setGamemode();

                    if (container.adder.getSGmod() == 0)
                    {
                        pg.setNome(container.adder.getName());
                        pg.setAlias(container.adder.getAlias());
                        pg.setDir(container.adder.getDir());
                        pg.setGameMode("", container.adder.getSGmod());

                        PanelEx panel = new PanelEx(container.contasoftware);
                        panel.addPBox(Resources.notSet);
                        panel.addTbox(pg.getLeft(), pg.getRight(), pg.getMiddle(), pg.getXb1(), pg.getXb2());
                        panel.addLabel(container.adder.getAlias());
                        panel.addTLbl();
                        panel.addButtons(cancelConfig, modifyConfig, ("CancS" + container.contasoftware.ToString()), ("ModS" + container.contasoftware.ToString()));
                        panel.setDir(pg.getDir());

                        container.allPanel.Add(panel);
                        container.ListConfig.Add(pg);
                        container.AllConfig.Add(pg);
                        container.p1.Controls.Add(panel.dynPanel);
                        container.addtoList(panel.Cancelbtn);

                        container.conta++;
                        container.contasoftware++;

                        if (container.contasoftware * (panel.dynPanel.Height) > container.p1.Height)
                        {
                            container.b1.Maximum = ((container.contasoftware * (panel.dynPanel.Height + 5)) - container.p1.Height + 58 + 29);
                        }
                    }
                    else
                    {
                        PanelEx panel = new PanelEx(container.contagames);

                        pg.setNome(container.adder.getName());
                        pg.setAlias(container.adder.getAlias());
                        pg.setDir(container.adder.getDir());
                        pg.setGameMode("", container.adder.getSGmod());

                        panel.addPBox(Resources.notSet);
                        panel.addTbox(pg.getLeft(), pg.getRight(), pg.getMiddle(), pg.getXb1(), pg.getXb2());
                        panel.addLabel(container.adder.getAlias());
                        panel.addTLbl();
                        panel.addButtons(cancelConfig, modifyConfig, ("CancG" + container.contagames.ToString()), ("ModG" + container.contagames.ToString()));
                        panel.setDir(pg.getDir());

                        container.allPanelGames.Add(panel);
                        container.ListConfigGames.Add(pg);
                        container.AllConfig.Add(pg);
                        container.p2.Controls.Add(panel.dynPanel);
                        container.addtoListGames(panel.Cancelbtn);

                        container.conta++;
                        container.contagames++;

                        if (container.contagames * (panel.dynPanel.Height) > container.p2.Height)
                        {
                            container.b2.Maximum = ((container.contagames * (panel.dynPanel.Height + 5)) - container.p2.Height + 58 + 29);
                        }
                    }
                    container.checkIfEmpty();
                    container.setPBox();
                    container.adder.clear();

                    this.Controls.Remove(container.adder.panel);
                }
                else
                {
                    MessageBox.Show("Devi prima inserire la posizione del programma!");
                }
            }
            else
            {
                container.adder.setAlias(container.adder.getAliasfromTxt());
                container.adder.setDir(container.adder.getDirfromTxt());
                container.adder.setGamemode();

                if (container.getWhat() == 1)
                {
                    //CERCO NELLA LISTA GIOCHI CHI HA toMod = 1
                    foreach (PanelEx panel in container.allPanelGames)
                    {
                        if (panel.gettoModify() == true)
                        {
                            foreach (ProgramConfiguration pg in container.ListConfigGames)
                            {
                                if (panel.getlblAlias().Equals(pg.getAlias()))
                                {
                                    panel.setAlias(container.adder.getAlias());
                                    panel.setDir(container.adder.getDir());
                                    pg.setAlias(panel.getlblAlias());
                                    pg.setDir(panel.getDir());
                                    pg.setNome(container.adder.getName());

                                    panel.setMod(0);
                                    container.setPBox();
                                }
                            }
                        }
                    }
                }
                else
                {
                    //CERCO NELLA LISTA SOFTWARE CHE HA toMod = 1
                    foreach (PanelEx panel in container.allPanel)
                    {
                        if (panel.gettoModify() == true)
                        {
                            foreach (ProgramConfiguration pg in container.ListConfig)
                            {
                                if (panel.getlblAlias().Equals(pg.getAlias()))
                                {
                                    panel.setAlias(container.adder.getAlias());
                                    panel.setDir(container.adder.getDir());
                                    pg.setAlias(panel.getlblAlias());
                                    pg.setDir(panel.getDir());
                                    pg.setNome(container.adder.getName());

                                    panel.setMod(0);
                                    container.setPBox();
                                }
                            }
                        }
                    }
                }
                container.adder.clear();
                this.Controls.Remove(container.adder.panel);
                this.is_customizating = false;
            }
        }
Exemple #2
0
        //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();
        }