|
@@ -2978,83 +2978,145 @@ namespace PDF_Master.ViewModels
|
|
|
/// <summary>
|
|
|
/// 另存为或新文档保存逻辑
|
|
|
/// </summary>
|
|
|
- public bool saveAsFile(Action RedactionAction = null)
|
|
|
+ public bool saveAsFile(Action RedactionAction = null,CPDFViewer cPDFViewer=null)
|
|
|
{
|
|
|
- bool flg = false;
|
|
|
- //删掉Settings.Default.UserDate.isInFreeUseTime == false,没有试用期策略了
|
|
|
- if (!App.IsLogin || Settings.Default.UserDate.subscribestatus !=1)
|
|
|
+ if(cPDFViewer==null)
|
|
|
{
|
|
|
- DialogParameters value = new DialogParameters();
|
|
|
- value.Add(ParameterNames.ViewContentViewModel, this);
|
|
|
- dialogs.ShowDialog(DialogNames.SubscriptionDialog, value, dialogResult =>
|
|
|
+ bool flg = false;
|
|
|
+ //删掉Settings.Default.UserDate.isInFreeUseTime == false,没有试用期策略了
|
|
|
+ if (!App.IsLogin || Settings.Default.UserDate.subscribestatus != 1)
|
|
|
{
|
|
|
- if (dialogResult.Result == ButtonResult.Cancel)
|
|
|
+ DialogParameters value = new DialogParameters();
|
|
|
+ value.Add(ParameterNames.ViewContentViewModel, this);
|
|
|
+ dialogs.ShowDialog(DialogNames.SubscriptionDialog, value, dialogResult =>
|
|
|
{
|
|
|
- flg = true;
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- if (flg == false)
|
|
|
- {
|
|
|
- return false;
|
|
|
- }
|
|
|
+ if (dialogResult.Result == ButtonResult.Cancel)
|
|
|
+ {
|
|
|
+ flg = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- }
|
|
|
- var dlg = new Microsoft.Win32.SaveFileDialog();
|
|
|
- dlg.Filter = Properties.Resources.OpenDialogFilter;
|
|
|
- dlg.FileName = PDFViewer.Document.FileName;
|
|
|
- if (dlg.ShowDialog() == true && !string.IsNullOrEmpty(dlg.FileName))
|
|
|
- {
|
|
|
- bool result = false;
|
|
|
- if (RedactionAction != null)
|
|
|
- {
|
|
|
- //保存前进行标记密文处理应用或擦除
|
|
|
- RedactionAction.Invoke();
|
|
|
- }
|
|
|
+ if (flg == false)
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- if (App.OpenedFileList.Contains(dlg.FileName))
|
|
|
- {
|
|
|
- //提示文件已经被打开
|
|
|
}
|
|
|
- else
|
|
|
+ var dlg = new Microsoft.Win32.SaveFileDialog();
|
|
|
+ dlg.Filter = Properties.Resources.OpenDialogFilter;
|
|
|
+ dlg.FileName = PDFViewer.Document.FileName;
|
|
|
+ if (dlg.ShowDialog() == true && !string.IsNullOrEmpty(dlg.FileName))
|
|
|
{
|
|
|
- string oldpath = PDFViewer.Document.FilePath;
|
|
|
- string openPassword = string.Empty;
|
|
|
- string permissionsPassword = string.Empty;
|
|
|
- CPDFPermissionsInfo cPDFPermissionsInfo = CreateDefaultPermissionsInfo();
|
|
|
- if (SecurityInfo.NeedOpenPassword)
|
|
|
+ bool result = false;
|
|
|
+ if (RedactionAction != null)
|
|
|
{
|
|
|
- openPassword = SecurityInfo.OpenPassword;
|
|
|
- passwordInfo.OpenPassword = openPassword;
|
|
|
+ //保存前进行标记密文处理应用或擦除
|
|
|
+ RedactionAction.Invoke();
|
|
|
}
|
|
|
|
|
|
- if (SecurityInfo.NeedPermissionsPassword)
|
|
|
+ if (App.OpenedFileList.Contains(dlg.FileName))
|
|
|
{
|
|
|
- permissionsPassword = SecurityInfo.PermissionsPassword;
|
|
|
- cPDFPermissionsInfo = SecurityInfo.CPDFPermissionsInfo;
|
|
|
+ //提示文件已经被打开
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string oldpath = PDFViewer.Document.FilePath;
|
|
|
+ string openPassword = string.Empty;
|
|
|
+ string permissionsPassword = string.Empty;
|
|
|
+ CPDFPermissionsInfo cPDFPermissionsInfo = CreateDefaultPermissionsInfo();
|
|
|
+ if (SecurityInfo.NeedOpenPassword)
|
|
|
+ {
|
|
|
+ openPassword = SecurityInfo.OpenPassword;
|
|
|
+ passwordInfo.OpenPassword = openPassword;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (SecurityInfo.NeedPermissionsPassword)
|
|
|
+ {
|
|
|
+ permissionsPassword = SecurityInfo.PermissionsPassword;
|
|
|
+ cPDFPermissionsInfo = SecurityInfo.CPDFPermissionsInfo;
|
|
|
|
|
|
- passwordInfo.PermissionsPassword = permissionsPassword;
|
|
|
+ passwordInfo.PermissionsPassword = permissionsPassword;
|
|
|
+ }
|
|
|
+
|
|
|
+ PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
|
|
|
+ result = PDFViewer.Document.WriteToFilePath(dlg.FileName);
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ mainViewModel.NewFile = false;
|
|
|
+ App.OpenedFileList.Remove(oldpath);
|
|
|
+ DoAfterSaveAs(dlg.FileName);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //提示文件被其他软件占用 无法保存
|
|
|
+ //
|
|
|
+ //Ex.Show(App.MainPageLoader.GetString("Main_TheFileOccupiedWarning"), "", Winform.MessageBoxButtons.OKCancel, new string[] { App.MainPageLoader.GetString("Main_SaveAs"), App.MainPageLoader.GetString("Main_Cancel") });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var dlg = new Microsoft.Win32.SaveFileDialog();
|
|
|
+ dlg.Filter = Properties.Resources.OpenDialogFilter;
|
|
|
+ dlg.FileName = cPDFViewer.Document.FileName;
|
|
|
+ if (dlg.ShowDialog() == true && !string.IsNullOrEmpty(dlg.FileName))
|
|
|
+ {
|
|
|
+ bool result = false;
|
|
|
+ if (RedactionAction != null)
|
|
|
+ {
|
|
|
+ //保存前进行标记密文处理应用或擦除
|
|
|
+ RedactionAction.Invoke();
|
|
|
}
|
|
|
|
|
|
- PDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
|
|
|
- result = PDFViewer.Document.WriteToFilePath(dlg.FileName);
|
|
|
- if (result)
|
|
|
+ if (App.OpenedFileList.Contains(dlg.FileName))
|
|
|
{
|
|
|
- mainViewModel.NewFile = false;
|
|
|
- App.OpenedFileList.Remove(oldpath);
|
|
|
- DoAfterSaveAs(dlg.FileName);
|
|
|
+ //提示文件已经被打开
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- //提示文件被其他软件占用 无法保存
|
|
|
- //
|
|
|
- //Ex.Show(App.MainPageLoader.GetString("Main_TheFileOccupiedWarning"), "", Winform.MessageBoxButtons.OKCancel, new string[] { App.MainPageLoader.GetString("Main_SaveAs"), App.MainPageLoader.GetString("Main_Cancel") });
|
|
|
+ string oldpath = cPDFViewer.Document.FilePath;
|
|
|
+ string openPassword = string.Empty;
|
|
|
+ string permissionsPassword = string.Empty;
|
|
|
+ CPDFPermissionsInfo cPDFPermissionsInfo = CreateDefaultPermissionsInfo();
|
|
|
+ if (SecurityInfo.NeedOpenPassword)
|
|
|
+ {
|
|
|
+ openPassword = SecurityInfo.OpenPassword;
|
|
|
+ passwordInfo.OpenPassword = openPassword;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (SecurityInfo.NeedPermissionsPassword)
|
|
|
+ {
|
|
|
+ permissionsPassword = SecurityInfo.PermissionsPassword;
|
|
|
+ cPDFPermissionsInfo = SecurityInfo.CPDFPermissionsInfo;
|
|
|
+
|
|
|
+ passwordInfo.PermissionsPassword = permissionsPassword;
|
|
|
+ }
|
|
|
+
|
|
|
+ cPDFViewer.Document.Encrypt(openPassword, permissionsPassword, cPDFPermissionsInfo);
|
|
|
+ result = cPDFViewer.Document.WriteToFilePath(dlg.FileName);
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ mainViewModel.NewFile = false;
|
|
|
+ App.OpenedFileList.Remove(oldpath);
|
|
|
+ DoAfterSaveAs(dlg.FileName);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //提示文件被其他软件占用 无法保存
|
|
|
+ //
|
|
|
+ //Ex.Show(App.MainPageLoader.GetString("Main_TheFileOccupiedWarning"), "", Winform.MessageBoxButtons.OKCancel, new string[] { App.MainPageLoader.GetString("Main_SaveAs"), App.MainPageLoader.GetString("Main_Cancel") });
|
|
|
+ }
|
|
|
}
|
|
|
+ return result;
|
|
|
}
|
|
|
- return result;
|
|
|
+ else
|
|
|
+ return false;
|
|
|
}
|
|
|
- else
|
|
|
- return false;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/// <summary>
|