private void Button_Click(object sender, RoutedEventArgs e) { if (txtKey.Password == "") { MessageBox.Show("请您输入秘钥!"); return; } if (txtKey.Password != txtKey2.Password) { MessageBox.Show("您输入俩次秘钥不相同!"); return; } FileLock fl = new FileLock(); if (IsOpenOrAdd) { bool compare = fl.Compare(txtKey.Password, Globals.FilePwd); txtKey.Password = ""; txtKey2.Password = ""; if (compare) { IsOpenOrAdd = false; BtnKey.Content = "加密"; } else { MessageBox.Show("您输入秘钥不正确!"); return; } } else { string Pwdword = fl.CreateKey(txtKey.Password); Globals.FilePwd = Pwdword; txtKey.Password = ""; txtKey2.Password = ""; BtnKey.Content = "解密"; IsOpenOrAdd = true; BtnPanel.Visibility = Visibility.Collapsed; KeyPanel.Visibility = Visibility.Collapsed; BtnOpen.Visibility = Visibility.Visible; } }