Пример #1
0
 private void savePasswordOk(object sender, RoutedEventArgs e)
 {
     if (passwordSaveBox.Password.Length < 6)
     {
         MessageBox.Show("Password must be 6 or more characters");
         passwordSaveBox.Password = "";
     }
     else
     {
         saveFilePopup.IsOpen = false;
         SaveFileDialog saveFile = new SaveFileDialog();
         saveFile.Filter = "UpRev Files|*.UpRev";
         if (saveFile.ShowDialog() == true)
         {
             using (var fileStream = File.Create(saveFile.FileName))
             {
                 TextRange range = new TextRange(rtbEditor.Document.ContentStart, rtbEditor.Document.ContentEnd);
                 range.Save(fileStream, DataFormats.Rtf);
             }
             if (PasswordVerification.isPasswordProtected(saveFile.FileName))
             {
                 PasswordVerification.updatePassword(saveFile.FileName);
             }
             string saveId      = IDVerification.getId();
             string newFileName = saveFile.FileName.Insert(0, saveId);
             string newPassword = passwordSaveBox.Password.Insert(0, saveId);
             Properties.Settings.Default.FileNames.Add(newFileName);
             Properties.Settings.Default.Passwords.Add(newPassword);
             Properties.Settings.Default.Save();
             Properties.Settings.Default.Reload();
             clearSaveItems();
         }
     }
 }
Пример #2
0
 private void checkOpenFile(string fileName)
 {
     id = IDVerification.getIdFromFileNames(fileName);
     if (id != "No files")
     {
         showOpenPasswordBox();
     }
     else
     {
         MessageBox.Show("This file isn't password protected");
         openFileActions(fileName);
         clearOpenItems();
     }
 }