Beispiel #1
0
 public ConfigForm(MainForm f)
 {
     InitializeComponent();
     //chargement des paramètres
     this.folders = Serialization.deserializeXML("folders.xml");
     this.files = new ArrayList();
     ImageList imgList = new ImageList();
     this.treeview.ImageList = imgList;
     this.treeViewFichiers.ImageList = imgList;
     imgList.Images.Add(System.Drawing.Image.FromFile(Environment.CurrentDirectory + @"/images/dossier_windows.png"));
     imgList.Images.Add(System.Drawing.Image.FromFile(Environment.CurrentDirectory + @"/images/fichier.jpg"));
     this.NUDInterval.Value = Convert.ToDecimal(ConfigurationManager.AppSettings["period"]);
     this.tbHour.Text = ConfigurationManager.AppSettings["heure"];
     this.tbMinutes.Text = ConfigurationManager.AppSettings["minute"];
     this.tbPath.Text = ConfigurationManager.AppSettings["path"];
     this.tbMDP.Text = ConfigurationManager.AppSettings["password"];
     Security sec = new Security();
     this.tbMDPAdmin.Text = sec.caesarToString(ConfigurationManager.AppSettings["passwordAdmin"],15);
     this.numericUpDown1.Value = Convert.ToDecimal(ConfigurationManager.AppSettings["nbSaves"]);
     this.tbFrom.Text = ConfigurationManager.AppSettings["from"];
     this.tbMDPFrom.Text = ConfigurationManager.AppSettings["MDPfrom"];
     this.tbSMTP.Text = ConfigurationManager.AppSettings["SMTP"];
     this.tbPort.Text = ConfigurationManager.AppSettings["port"];
     this.tbTo.Text = ConfigurationManager.AppSettings["to"];
     if (ConfigurationManager.AppSettings["SSL"] == "1")
     { this.cbSSL.Checked = true; }
     this.ancienInterval = this.NUDInterval.Value.ToString();
     this.toolTip1.ToolTipIcon = ToolTipIcon.Warning;
     this.form = f;
     this.populatetreeView();
     this.form.configFormThread.Abort();
 }
Beispiel #2
0
        public void saveConfig()
        {
            //ouverture du fichier de configuration
            System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            //sauvegarde de l'heure de la sauvegarde
            //sauvegarde de la minute de la sauvegarde
            //sauvegarde du chemin du repertoire de destination de la sauvegarde
            //sauvegarde de l'intervalle en jours entre 2 sauvegardes
            config.AppSettings.Settings.Remove("heure");
            config.AppSettings.Settings.Add("heure", this.tbHour.Text);
            config.AppSettings.Settings.Remove("minute");
            config.AppSettings.Settings.Add("minute", this.tbMinutes.Text);
            config.AppSettings.Settings.Remove("path");
            config.AppSettings.Settings.Add("path", this.tbPath.Text);
            config.AppSettings.Settings.Remove("period");
            config.AppSettings.Settings.Add("period", this.NUDInterval.Value.ToString());
            //si la zone de texte permettant de changer le mot de passe est visible
            //sauvegarde du mot de passe
            if (this.tbConfirmMDP.Visible == true)
            {
                config.AppSettings.Settings.Remove("password");
                config.AppSettings.Settings.Add("password", this.tbMDP.Text);
            }
            //si la zone de texte permettant de changer le mot de passe administrateur est visible
            //sauvegarde du mot de passe administrateur
            if (this.tbConfirmMDPAdmin.Visible == true)
            {
                Security sec = new Security();
                config.AppSettings.Settings.Remove("passwordAdmin");
                config.AppSettings.Settings.Add("passwordAdmin",sec.toCaesar(this.tbMDPAdmin.Text,15));
                Serialization.serializeMDPAdmin(sec.toCaesar(this.tbMDPAdmin.Text, 15));
            }
            //sauvegarde du nombre de sauvegardes à conserver
            config.AppSettings.Settings.Remove("nbSaves");
            config.AppSettings.Settings.Add("nbSaves", this.numericUpDown1.Value.ToString());

            //sauvegarde des paramètres d'envoi de mails
            config.AppSettings.Settings.Remove("from");
            config.AppSettings.Settings.Remove("MDPFrom");
            config.AppSettings.Settings.Remove("SMTP");
            config.AppSettings.Settings.Remove("port");
            config.AppSettings.Settings.Remove("to");
            config.AppSettings.Settings.Remove("SSL");
            config.AppSettings.Settings.Add("from", this.tbFrom.Text);
            config.AppSettings.Settings.Add("MDPfrom", this.tbMDPFrom.Text);
            config.AppSettings.Settings.Add("SMTP", this.tbSMTP.Text);
            config.AppSettings.Settings.Add("port", this.tbPort.Text);
            config.AppSettings.Settings.Add("to", this.tbTo.Text);
            if (this.cbSSL.Checked)
            { config.AppSettings.Settings.Add("SSL", "1"); }
            else
            { config.AppSettings.Settings.Add("SSL", "0"); }

            ConfigurationManager.RefreshSection("appSettings");
            config.Save(ConfigurationSaveMode.Modified);
            Serialization.deserializeLastSaveDate(true);
        }
Beispiel #3
0
 public void checkMDP()
 {
     Security secure = new Security();
     //this.ok = Security.compareToMd5(this.tbMDP.Text,this.mdp);
     this.ok = this.mdp.Equals(secure.toCaesar(this.tbMDP.Text , 15));
 }