Example #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     if (File.Exists(confFilePath))
     {
         FileStream      fs  = new FileStream(confFilePath, FileMode.Open);
         BinaryFormatter bf  = new BinaryFormatter();
         FormConfEntity  fce = (FormConfEntity)bf.Deserialize(fs);
         fs.Close();
         comboBox1.Items.AddRange(fce.TXTPath.ToArray());
         comboBox2.Items.AddRange(fce.Workspace.ToArray());
         comboBox3.Items.AddRange(fce.OutFolder.ToArray());
         comboBox4.Items.AddRange(fce.OutFolderAdd.ToArray());
         comboBox5.Items.AddRange(fce.ReplaceSource.ToArray());
         comboBox6.Items.AddRange(fce.ReplaceTarget.ToArray());
         checkBox1.Checked = fce.GainClass;
         checkBox2.Checked = fce.RetainDirectory;
         checkBox3.Checked = fce.GainTarGz;
     }
     else
     {
         this.comboBox1.Items.Add(@"F:\demo\demo.txt");
         this.comboBox2.Items.Add(@"E:\workspace");
         this.comboBox3.Items.Add(@"F:\demo");
         this.comboBox4.Items.Add(@"2018-4-18");
         this.comboBox5.Items.Add(@"src/");
         this.comboBox6.Items.Add(@"hxbroot\WEB-INF\classes\");
     }
     this.comboBox1.SelectedIndex = 0;
     this.comboBox2.SelectedIndex = 0;
     this.comboBox3.SelectedIndex = 0;
     this.comboBox4.SelectedIndex = 0;
     this.comboBox5.SelectedIndex = 0;
     this.comboBox6.SelectedIndex = 0;
 }
Example #2
0
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            //用配置文件缓存所有控件
            FormConfEntity formConfEntity = new FormConfEntity()
            {
                TXTPath         = itemsToList(comboBox1),
                Workspace       = itemsToList(comboBox2),
                OutFolder       = itemsToList(comboBox3),
                OutFolderAdd    = itemsToList(comboBox4),
                ReplaceSource   = itemsToList(comboBox5),
                ReplaceTarget   = itemsToList(comboBox6),
                GainClass       = checkBox1.Checked,
                RetainDirectory = checkBox2.Checked,
                GainTarGz       = checkBox3.Checked
            };

            FileStream      fs = new FileStream(confFilePath, FileMode.Create);
            BinaryFormatter bf = new BinaryFormatter();

            bf.Serialize(fs, formConfEntity);
            fs.Close();
        }