//窗体加载 private void FormChooser_Load(object sender, EventArgs e) { binFile = OpenFile("选择库文件(*.bin)|*.bin"); if (binFile == "") { ClassLibrary.Chooser.Chooser chooser1 = new ClassLibrary.Chooser.Chooser(); chooserBindingSource.Add(chooser1); MessageBox.Show("没选择库文件,选择库将放在程序当前文件夹的 Choose.bin!"); } else { Encrypt_Decrypt ed = new Encrypt_Decrypt(binFile); ClassLibrary.Chooser.Chooser chooser = new ClassLibrary.Chooser.Chooser(); chooser = (ClassLibrary.Chooser.Chooser)ed.DeSerialize(); chooserBindingSource.Add(chooser); comboBoxModeEnum.SelectedIndex = chooser.ModeEnum; } checkBox6_CheckedChanged(this, null); }
//保存 private void saveToolStripMenuItem_Click(object sender, EventArgs e) { this.Validate(); this.chooserBindingSource.EndEdit(); if (binFile == "") { Encrypt_Decrypt ed = new Encrypt_Decrypt(Application.StartupPath + "\\Choose.bin"); //ed.Serialize((ClassLibrary.Chooser.Chooser)bindingSourceChooser[0]); ClassLibrary.Chooser.Chooser chooser = (ClassLibrary.Chooser.Chooser)chooserBindingSource[0]; chooser.ModeEnum = (int)comboBoxModeEnum.SelectedIndex; ed.Serialize(chooser); } else { Encrypt_Decrypt ed = new Encrypt_Decrypt(binFile); ClassLibrary.Chooser.Chooser chooser = (ClassLibrary.Chooser.Chooser)chooserBindingSource[0]; chooser.ModeEnum = (int)comboBoxModeEnum.SelectedIndex; ed.Serialize(chooser); } }