private void DoCmdSecurity() { GenericMessageAction <MsgShowSecurity, MsgOpenFile> message = new GenericMessageAction <MsgShowSecurity, MsgOpenFile>( new MsgShowSecurity(this._doc), this.MsgOpenFile_Handler); Messenger.Default.Send(message); }
private void DoCmdDropFiles(System.Windows.DragEventArgs e) { if (e.Data.GetDataPresent(System.Windows.DataFormats.FileDrop)) { string[] droppedFilePaths = e.Data.GetData(System.Windows.DataFormats.FileDrop, true) as string[]; this.Files.Clear(); // Add only valid PDF files foreach (string path in droppedFilePaths) { if (PDFDocument.PDFCheck(path)) { this.Files.Add(path); } } // Only one file: open it in the main window if (this.Files.Count == 1) { this.MsgOpenFile_Handler(new MsgOpenFile(this.Files[0], true, false)); } // Shows the window for merging documents, if more than one file is dropped to the window if (this.Files.Count > 1) { GenericMessageAction <MsgShowMergeDocuments, MsgOpenFile> message = new GenericMessageAction <MsgShowMergeDocuments, MsgOpenFile>( new MsgShowMergeDocuments(this.Files), this.MsgOpenFile_Handler); Messenger.Default.Send(message); } } }
private void DoCmdRotatePages() { GenericMessageAction <MsgShowRotatePages, MsgOpenFile> message = new GenericMessageAction <MsgShowRotatePages, MsgOpenFile>( new MsgShowRotatePages(this._doc), this.MsgOpenFile_Handler); Messenger.Default.Send(message); }
private void DoCmdOpenDocument() { GenericMessageAction <MsgOpenFile, MsgOpenFile> message = new GenericMessageAction <MsgOpenFile, MsgOpenFile>( new MsgOpenFile() { NewFile = true }, this.MsgOpenFile_Handler); Messenger.Default.Send(message); }
// --- OPEN FOLDER void MsgOpenFolder_Handler(GenericMessageAction <MsgSelectFolder, string> msg) //MsgSelectFolder msg) { System.Windows.Forms.FolderBrowserDialog fbd = new System.Windows.Forms.FolderBrowserDialog(); fbd.Description = msg.Data.Description; if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { msg.Execute(fbd.SelectedPath); } }
private void DoCmdBrowse() { GenericMessageAction <MsgSelectFolder, string> message = new GenericMessageAction <MsgSelectFolder, string>( new MsgSelectFolder() { Description = App.Current.FindResource("loc_burstFolderBrowserDialogDescription").ToString() }, x => this.WorkingDirectory = x); Messenger.Default.Send(message); }
// --- OPEN FILE void MsgOpenFile_Handler(GenericMessageAction <MsgOpenFile, MsgOpenFile> msg) { MsgOpenFile data = msg.Data; FileDialogResult r = DialogController.ShowOpenFileDialog(data.Multiselect); data.FileName = r.FileName; data.FileNames = r.FileNames; data.NewFile = r.CommonDialogReturn; msg.Execute(data); }
private void MsgShowEnterPassword_Handler(GenericMessageAction <MsgShowEnterPassword, string> msg) { WndEnterPassword wndEnterPassword = new WndEnterPassword(); WndEnterPasswordViewModel wndEnterPasswordViewModel = new WndEnterPasswordViewModel(msg.Data.Document); wndEnterPassword.DataContext = wndEnterPasswordViewModel; ShowWindow(wndEnterPassword, true); string ret = wndEnterPasswordViewModel.ReturnValue as string; msg.Execute(ret); }
// --- SECURITY void MsgShowSecurity_Handler(GenericMessageAction <MsgShowSecurity, MsgOpenFile> msg) { WndSecurity wndSecurity = new WndSecurity(); WndSecurityViewModel wndSecurityViewModel = new WndSecurityViewModel(msg.Data.Document); wndSecurity.DataContext = wndSecurityViewModel; ShowWindow(wndSecurity, true); string tempFile = wndSecurityViewModel.ReturnValue as string; msg.Execute(new MsgOpenFile(tempFile)); }
private void MsgShowConfirmPassword_Handler(GenericMessageAction <MsgShowConfirmPassword, bool> msg) { WndConfirmPassword wndConfirmPassword = new WndConfirmPassword(); WndConfirmPasswordViewModel wndConfirmPasswordViewModel = new WndConfirmPasswordViewModel(msg.Data.PasswordType, msg.Data.OriginalPassword); wndConfirmPassword.DataContext = wndConfirmPasswordViewModel; ShowWindow(wndConfirmPassword, true); bool ret = wndConfirmPasswordViewModel.ReturnValue == null ? false : (bool)wndConfirmPasswordViewModel.ReturnValue; msg.Execute(ret); }
// --- ROTATE PAGES void MsgShowRotatePages_Handler(GenericMessageAction <MsgShowRotatePages, MsgOpenFile> msg) { WndRotatePages wndRotatePages = new WndRotatePages(); WndRotatePagesViewModel wndRotatePagesViewModel = new WndRotatePagesViewModel(msg.Data.Document); wndRotatePages.DataContext = wndRotatePagesViewModel; ShowWindow(wndRotatePages, true); string tempFile = wndRotatePagesViewModel.ReturnValue as string; msg.Execute(new MsgOpenFile(tempFile)); }
// --- MERGE DOCUMENTS void MsgShowMergeDocuments_Handler(GenericMessageAction <MsgShowMergeDocuments, MsgOpenFile> msg) { WndMergeDocuments wndMergeDocuments = new WndMergeDocuments(); WndMergeDocumentsViewModel wndMergeDocumentsViewModel = new WndMergeDocumentsViewModel(msg.Data.FilesToMerge); wndMergeDocuments.DataContext = wndMergeDocumentsViewModel; ShowWindow(wndMergeDocuments, true); string tempFile = wndMergeDocumentsViewModel.ReturnValue as string; msg.Execute(new MsgOpenFile(tempFile)); }
private void DoCmdAddFile() { GenericMessageAction <MsgOpenFile, MsgOpenFile> message = new GenericMessageAction <MsgOpenFile, MsgOpenFile>( new MsgOpenFile() { Multiselect = true }, x => { this.AddFiles(x.FileNames); }); Messenger.Default.Send <GenericMessageAction <MsgOpenFile, MsgOpenFile> >(message); }
private void DoCmdMergeDocuments() { MsgShowMergeDocuments msg = new MsgShowMergeDocuments(); if ((this._doc != null) && (this._doc.HasInfo)) { msg.FilesToMerge.Add(this._doc.FullName); } GenericMessageAction <MsgShowMergeDocuments, MsgOpenFile> message = new GenericMessageAction <MsgShowMergeDocuments, MsgOpenFile>( msg, this.MsgOpenFile_Handler); Messenger.Default.Send(message); }
private void DoCmdSaveDocument() { GenericMessageAction <MsgSaveFile, MsgOpenFile> message = new GenericMessageAction <MsgSaveFile, MsgOpenFile>( new MsgSaveFile(), x => { if (x.NewFile) { // Always overwrite. Don't check here if the file already exists! System.IO.File.Copy(this.Uri, x.FileName, true); this.MsgOpenFile_Handler(x); } }); Messenger.Default.Send(message); }
private void DoCmdClosing(System.ComponentModel.CancelEventArgs e) { // If the document is not changed just close the window if (!this.IsDocumentChanged) { return; } string msg = App.Current.FindResource("loc_msgSaveChanges").ToString(); DialogMessage dialogMessage = new DialogMessage(msg, x => { if (x == System.Windows.MessageBoxResult.Cancel) { e.Cancel = true; } else if (x == System.Windows.MessageBoxResult.Yes) { GenericMessageAction <MsgSaveFile, MsgOpenFile> message = new GenericMessageAction <MsgSaveFile, MsgOpenFile>(new MsgSaveFile(), y => { if (y.FileName != "") { // Always overwrite. Don't check here if the file already exists! System.IO.File.Copy(this.Uri, (string)y.FileName, true); } else { e.Cancel = true; } }); Messenger.Default.Send(message); } Properties.Settings.Default.Save(); }) { Button = System.Windows.MessageBoxButton.YesNoCancel, Icon = System.Windows.MessageBoxImage.Question }; Messenger.Default.Send(dialogMessage); }
private void DoCmdInsertPages() { GenericMessageAction <MsgOpenFile, MsgOpenFile> openfile_message = new GenericMessageAction <MsgOpenFile, MsgOpenFile>( new MsgOpenFile(), x => { if (x.FileName != "") { GenericMessageAction <MsgShowInsertPages, MsgOpenFile> message = new GenericMessageAction <MsgShowInsertPages, MsgOpenFile>( new MsgShowInsertPages(this._doc) { FileToMerge = x.FileName }, this.MsgOpenFile_Handler); Messenger.Default.Send(message); } }); Messenger.Default.Send(openfile_message); }
private void DoCmdSetPasswords() { SecureString confirmedOpenPassword = null; SecureString confirmedEditPassword = null; if (this.SetOpenPassword == true) { GenericMessageAction <MsgShowConfirmPassword, bool> message = new GenericMessageAction <MsgShowConfirmPassword, bool>( new MsgShowConfirmPassword(this._openPassword, PasswordTypes.Open), x => confirmedOpenPassword = (x == true) ? this._openPassword : null); Messenger.Default.Send(message); } if (this.SetEditPassword == true) { GenericMessageAction <MsgShowConfirmPassword, bool> message = new GenericMessageAction <MsgShowConfirmPassword, bool>( new MsgShowConfirmPassword(this._editPassword, PasswordTypes.Edit), x => confirmedEditPassword = (x == true) ? this._editPassword : null); Messenger.Default.Send(message); } if ((confirmedOpenPassword != null) || (confirmedEditPassword != null)) { string tempFileName = String.Format(App.Current.FindResource("loc_tempEncrypted").ToString(), System.IO.Path.GetFileNameWithoutExtension(this._doc.FileName)) + System.IO.Path.GetExtension(this._doc.FileName); string tempFile = System.IO.Path.Combine(App.TEMP_DIR, tempFileName); PDFActions pdfActions = new PDFActions(); PDFActions.OperationStates state = pdfActions.Encrypt(this._doc, confirmedOpenPassword, confirmedEditPassword, this.AllowPrinting, this.AllowDegradatedPrinting, this.AllowModifyContents, this.AllowAssembly, this.AllowCopyContents, this.AllowScreenReaders, this.AllowModifyAnnotations, this.AllowFillIn, this.AllowAll, ref tempFile); this.Close(tempFile); } }
void StartupInitializations() { // Handles command line arguments string[] args = Environment.GetCommandLineArgs(); if (args.Length > 1) { // Define some variables to store informations passed via command line arguments bool documentChanged = false; // The first argument returned by Environment.GetCommandLineArgs() is the // program executable, so I bypass it. for (int i = 1; i < args.Length; i++) { string a = args[i]; // Handles simple command line options (e.g. "/C") if (a.StartsWith("/")) // process the options { switch (a) { case App.CLO_DOCUMENT_CHANGED: documentChanged = true; break; } } else // get the file names { this.Files.Add(a); } } if (this.Files.Count == 1) { // Only one file: open it in the main window this.Uri = this.Files[0]; // Set initial informations this.IsDocumentChanged = documentChanged; } } // Operation to do only if the temporary directory is not in use or // if there isn't another PDF Rider process running. if ((System.Diagnostics.Process.GetProcessesByName(App.PROCESS_NAME).Length == 1) && (!this.Uri.StartsWith(App.TEMP_DIR))) // Use the following lines for debug //if ((System.Diagnostics.Process.GetProcessesByName("PDFRider.vshost.exe").Length <= 1) && // (!this.Uri.StartsWith(App.TEMP_DIR))) { // Deletes the temporary files this.DeleteTempFiles(); } // Shows the window for merging documents, if more than one file is passed in Arguments list if (this.Files.Count > 1) { GenericMessageAction <MsgShowMergeDocuments, MsgOpenFile> message = new GenericMessageAction <MsgShowMergeDocuments, MsgOpenFile>( new MsgShowMergeDocuments(this.Files), this.MsgOpenFile_Handler); Messenger.Default.Send(message); } }
// --- SAVE FILE void MsgSaveFile_Handler(GenericMessageAction <MsgSaveFile, MsgOpenFile> msg) { FileDialogResult r = DialogController.ShowSaveFileDialog(); msg.Execute(new MsgOpenFile(r.FileName, r.CommonDialogReturn)); }
private void DoCmdRemovePasswords() { System.Security.SecureString password = new SecureString(); GenericMessageAction <MsgShowEnterPassword, System.Security.SecureString> message = new GenericMessageAction <MsgShowEnterPassword, System.Security.SecureString>( new MsgShowEnterPassword(this._doc), x => password = x); Messenger.Default.Send(message); if (password != null) { string tempFileName = String.Format(App.Current.FindResource("loc_tempDecrypted").ToString(), System.IO.Path.GetFileNameWithoutExtension(this._doc.FileName)) + System.IO.Path.GetExtension(this._doc.FileName); string tempFile = System.IO.Path.Combine(App.TEMP_DIR, tempFileName); PDFActions pdfActions = new PDFActions(); PDFActions.OperationStates state = pdfActions.Decrypt(this._doc, password, ref tempFile); this.Close(tempFile); } }