コード例 #1
0
        private void Encrypt_Button_Click(object sender, RoutedEventArgs e)
        {
            var           _fileList                 = explorer.ViewModel.FileList.Selection.SelectedItems;
            List <string> encryptedFileNames        = new List <string>();
            Boolean       isCancelEncryptionProcess = false;

            foreach (var el in _fileList)
            {
                if (System.IO.Path.GetExtension(el.EntryModel.FullPath) == Securebox.secureboxExtension)
                {
                    //System.Windows.Forms.DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("File is already encrypted, press \"Cancel\" to skip remaining selected file(s), press \"Ok\" to continue", "File is already encrypted by Securebox", MessageBoxButtons.OKCancel);
                    //isCancelEncryptionProcess = dialogResult == System.Windows.Forms.DialogResult.Cancel;
                }
                else
                {
                    Guid g;
                    // Create and display the value of two GUIDs.
                    g = Guid.NewGuid();
                    Securebox.EncryptFile(el.EntryModel.FullPath, el.EntryModel.FullPath + ".tmp", g);
                    isCancelEncryptionProcess = Securebox.PostProcessEncryptFile(el.EntryModel.FullPath + ".tmp", el.EntryModel.FullPath + ".box", g);
                    encryptedFileNames.Add(System.IO.Path.GetFileName(el.EntryModel.FullPath));
                }

                if (isCancelEncryptionProcess)
                {
                    break;
                }
            }
            var            report = String.Join("\n", encryptedFileNames.ToArray());
            IScriptCommand cmd    = UIScriptCommands.FileListRefresh(true, UIScriptCommands.MessageBoxOK("Report", report));

            explorer.ViewModel.Commands.ExecuteAsync(cmd);
        }
コード例 #2
0
        private void Decrypt_Button_Click(object sender, RoutedEventArgs e)
        {
            //FileExplorer.WPF.UserControls.Explorer exp = explorer as FileExplorer.WPF.UserControls.Explorer;
            var _fileList = explorer.ViewModel.FileList.Selection.SelectedItems;

            foreach (var el in _fileList)
            {
                //Debug.WriteLine(el.EntryModel.FullPath);
                Securebox.DecryptPreprocess(el.EntryModel.FullPath);
                //Helper.DecryptFile(el.EntryModel.FullPath, el.EntryModel.FullPath + ".sbox", g.ToString());
                // Debug.WriteLine(el.ToString());
            }
            IScriptCommand cmd = UIScriptCommands.FileListRefresh(true, UIScriptCommands.MessageBoxOK("Refresh", "File(s) Decrypted"));

            explorer.ViewModel.Commands.ExecuteAsync(cmd);
        }
コード例 #3
0
        private void ExportButton_Click(object sender, RoutedEventArgs e)
        {
            //export db
            // Displays a SaveFileDialog so the user can save the Image
            // assigned to Button2.
            Microsoft.Win32.SaveFileDialog saveFileDialog1 = new Microsoft.Win32.SaveFileDialog();
            saveFileDialog1.Filter = "Securebox key file (.sbox)|*.sbox"; // Filter files by extension
            saveFileDialog1.Title  = "Export and save Securebox key file";
            saveFileDialog1.ShowDialog();

            // If the file name is not an empty string open it for saving.
            if (saveFileDialog1.FileName != "")
            {
                // Saves the Image via a FileStream created by the OpenFile method.
                //System.IO.FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile();
                // Saves the Image in the appropriate ImageFormat based upon the
                // File type selected in the dialog box.
                // NOTE that the FilterIndex property is one-based.
                File.Copy(DatabaseManagement.GetDBFullPath(), saveFileDialog1.FileName, true);
                IScriptCommand cmd = UIScriptCommands.FileListRefresh(true, UIScriptCommands.MessageBoxOK("Refresh", "Securebox key file exported"));
                explorer.ViewModel.Commands.ExecuteAsync(cmd);
                //fs.Close();
            }
        }
コード例 #4
0
        private void RefreshView()
        {
            IScriptCommand cmd = UIScriptCommands.FileListRefresh(true);

            explorer.ViewModel.Commands.ExecuteAsync(cmd);
        }