|
@@ -33,15 +33,17 @@ using static PDF_Master.Model.Dialog.ToolsDialogs.SaftyDialogs.DeleteSafetySetti
|
|
|
|
|
|
namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
{
|
|
|
- class MergeDialogViewModel : BindableBase, IDialogAware
|
|
|
+ internal class MergeDialogViewModel : BindableBase, IDialogAware
|
|
|
{
|
|
|
// Fix:存储当前程序加载的文档的路径和tag,
|
|
|
//如果路径相同则用tag里的密码解锁,
|
|
|
//解锁失败再另行提权
|
|
|
private string CurrentFilePath = string.Empty;
|
|
|
+
|
|
|
private string currentLoadedPassword = string.Empty;
|
|
|
- private IEventAggregator eventAggregator;
|
|
|
- enum PageSizeType
|
|
|
+ private IEventAggregator eventAggregator;
|
|
|
+
|
|
|
+ private enum PageSizeType
|
|
|
{
|
|
|
kDefault = 0,
|
|
|
A4 = 1,
|
|
@@ -63,8 +65,7 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
}
|
|
|
|
|
|
public void OnDialogClosed()
|
|
|
- {
|
|
|
-
|
|
|
+ {
|
|
|
}
|
|
|
|
|
|
public void OnDialogOpened(IDialogParameters parameters)
|
|
@@ -112,7 +113,8 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
+ #endregion 框架内容
|
|
|
+
|
|
|
#region 定义与初始化
|
|
|
|
|
|
public ObservableCollection<MergeObject> MergeObjectlist { get; set; }
|
|
@@ -143,6 +145,7 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
}
|
|
|
|
|
|
private Visibility processVisible = Visibility.Collapsed;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 是否显示进度条
|
|
|
/// </summary>
|
|
@@ -156,6 +159,7 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
}
|
|
|
|
|
|
private bool _AddOpenFileIsEn = false;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 添加已打开文件是否置灰
|
|
|
/// </summary>
|
|
@@ -167,6 +171,7 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
SetProperty(ref _AddOpenFileIsEn, value);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
private string inputHeight;
|
|
|
|
|
|
public string InputHeight
|
|
@@ -179,6 +184,7 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
}
|
|
|
|
|
|
private double maxValue;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 最大文件数 用于显示进度条
|
|
|
/// </summary>
|
|
@@ -204,15 +210,18 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
SetProperty(ref currentvalue, value);
|
|
|
}
|
|
|
}
|
|
|
- /// <summary>
|
|
|
- /// 订阅按钮
|
|
|
- /// </summary>
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 订阅按钮
|
|
|
+ /// </summary>
|
|
|
private string _TextUpgrade;
|
|
|
+
|
|
|
public string TextUpgrade
|
|
|
{
|
|
|
get { return _TextUpgrade; }
|
|
|
set { _TextUpgrade = value; }
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 是否显示限制字段
|
|
|
/// </summary>
|
|
@@ -231,9 +240,8 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
/// 是否取消添加文件
|
|
|
/// </summary>
|
|
|
|
|
|
- private bool CancelAddFiles = false;
|
|
|
-
|
|
|
-
|
|
|
+ private bool CancelAddFiles = false;
|
|
|
+
|
|
|
public MergeDialogViewModel(IDialogService dialogService, IEventAggregator eventAggregator)
|
|
|
{
|
|
|
IntString();
|
|
@@ -249,6 +257,7 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
CancelAddFileCommand = new DelegateCommand(CancelAddFileOpention);
|
|
|
UnlockMouseDownCommand = new DelegateCommand(UnlockMouseDown);
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 多语
|
|
|
/// </summary>
|
|
@@ -257,14 +266,15 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
TextUpgrade = App.ServiceLoader.GetString("TextUpgrade");
|
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
+ #endregion 定义与初始化
|
|
|
|
|
|
#region 私有方法
|
|
|
|
|
|
private void UnlockMouseDown()
|
|
|
{
|
|
|
ConverterHelper.convertUnlock();
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
private void CancelAddFileOpention()
|
|
|
{
|
|
|
CancelAddFiles = true;
|
|
@@ -284,6 +294,7 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
Clear();
|
|
|
RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 点击取消页面范围控件使失去焦点不生效
|
|
|
/// </summary>
|
|
@@ -307,6 +318,7 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
public void ButtonAddFiles(object data)
|
|
|
{
|
|
|
int index = Convert.ToInt32(data);
|
|
@@ -316,11 +328,13 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
case 0:
|
|
|
//打开文件
|
|
|
AddFiles(OpenFile());
|
|
|
- break;
|
|
|
+ break;
|
|
|
+
|
|
|
case 1:
|
|
|
//打开文件夹
|
|
|
AddFiles(OpenFileFolder());
|
|
|
- break;
|
|
|
+ break;
|
|
|
+
|
|
|
case 2:
|
|
|
//打开当前文件
|
|
|
List<string> list = new List<string>();
|
|
@@ -330,7 +344,8 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
list.Add(App.OpenedFileList[i]);
|
|
|
}
|
|
|
AddFiles(list.ToArray());
|
|
|
- break;
|
|
|
+ break;
|
|
|
+
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -342,7 +357,7 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
private void AddOpenFileIsEnChange()
|
|
|
{
|
|
|
AddOpenFileIsEn = false;
|
|
|
- if (MergeObjectlist.Count> App.OpenedFileList.Count)
|
|
|
+ if (MergeObjectlist.Count > App.OpenedFileList.Count)
|
|
|
{
|
|
|
AddOpenFileIsEn = true;
|
|
|
return;
|
|
@@ -365,9 +380,8 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
private string[] OpenFileFolder()
|
|
|
{
|
|
|
System.Windows.Forms.FolderBrowserDialog openFile = new System.Windows.Forms.FolderBrowserDialog();
|
|
@@ -395,7 +409,8 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
}
|
|
|
|
|
|
return list.ToArray();
|
|
|
- }
|
|
|
+ }
|
|
|
+
|
|
|
private string[] OpenFile()
|
|
|
{
|
|
|
OpenFileDialog openFile = new OpenFileDialog();
|
|
@@ -410,7 +425,6 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
|
|
|
private void Merge()
|
|
|
{
|
|
|
-
|
|
|
bool result = true;
|
|
|
CPDFDocument SaveDoc = CPDFDocument.CreateDocument();
|
|
|
int sum = MergeObjectlist.Count;
|
|
@@ -423,7 +437,8 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
List<int> listnum = new List<int>();
|
|
|
if (MergeObjectlist[i].SetPageRange == null || MergeObjectlist[i].SetPageRange.Count == 0)
|
|
|
{
|
|
|
- if (MergeObjectlist[i].SDKPageCount == 0) {
|
|
|
+ if (MergeObjectlist[i].SDKPageCount == 0)
|
|
|
+ {
|
|
|
AlertsMessage alertsMessage = new AlertsMessage();
|
|
|
alertsMessage.ShowDialog("", App.MainPageLoader.GetString("PageRangeWarning"), App.ServiceLoader.GetString("Text_ok"));
|
|
|
return;
|
|
@@ -434,7 +449,6 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
pageRangeList.Add(page1);
|
|
|
}
|
|
|
MergeObjectlist[i].SetPageRange = pageRangeList;
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -474,8 +488,7 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
catch
|
|
|
{
|
|
|
continue;
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -554,24 +567,29 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
switch (pageSizeType)
|
|
|
{
|
|
|
case PageSizeType.kDefault:
|
|
|
- break;
|
|
|
+ break;
|
|
|
+
|
|
|
case PageSizeType.A4:
|
|
|
|
|
|
rect.Width = CommonHelper.GetPageSizeFomrUnit(210);
|
|
|
rect.Height = CommonHelper.GetPageSizeFomrUnit(297);
|
|
|
- break;
|
|
|
+ break;
|
|
|
+
|
|
|
case PageSizeType.A3:
|
|
|
rect.Width = CommonHelper.GetPageSizeFomrUnit(297);
|
|
|
rect.Height = CommonHelper.GetPageSizeFomrUnit(420);
|
|
|
- break;
|
|
|
+ break;
|
|
|
+
|
|
|
case PageSizeType.Letter:
|
|
|
rect.Width = CommonHelper.GetPageSizeFomrUnit(216);
|
|
|
rect.Height = CommonHelper.GetPageSizeFomrUnit(279);
|
|
|
- break;
|
|
|
+ break;
|
|
|
+
|
|
|
case PageSizeType.Legal:
|
|
|
rect.Width = CommonHelper.GetPageSizeFomrUnit(216);
|
|
|
rect.Height = CommonHelper.GetPageSizeFomrUnit(356);
|
|
|
- break;
|
|
|
+ break;
|
|
|
+
|
|
|
case PageSizeType.Customized:
|
|
|
if (!string.IsNullOrEmpty(InputWidth) && !string.IsNullOrEmpty(InputHeight))
|
|
|
{
|
|
@@ -583,7 +601,8 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
rect.Width = CommonHelper.GetPageSizeFomrUnit(595);
|
|
|
rect.Height = CommonHelper.GetPageSizeFomrUnit(841);
|
|
|
}
|
|
|
- break;
|
|
|
+ break;
|
|
|
+
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -619,7 +638,7 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
+ #endregion 私有方法
|
|
|
|
|
|
#region 公开方法
|
|
|
|
|
@@ -660,10 +679,17 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
+ if (Settings.Default.UserDate.subscribestatus != 1 && MergeObjectlist.Count >= 2)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
bool showDialog = false;
|
|
|
ProcessVisible = Visibility.Visible;
|
|
|
MaxValue = FilePath.Length;
|
|
|
- for (int i = 0; i < FilePath.Length; i++)
|
|
|
+
|
|
|
+ int sum = SetFilesLength(FilePath);
|
|
|
+
|
|
|
+ for (int i = 0; i < sum; i++)
|
|
|
{
|
|
|
//加入异步语句,防止UI卡死,显示加载进度条
|
|
|
await System.Threading.Tasks.Task.Delay(1);
|
|
@@ -763,7 +789,6 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
VerifyPasswordResult condition = new VerifyPasswordResult();
|
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
|
{
|
|
@@ -777,7 +802,6 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
mergeObject.Password = condition.Password;
|
|
|
if (doc.UnlockWithPassword(condition.Password) && doc.CheckOwnerPassword(condition.Password))
|
|
|
{
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -786,8 +810,6 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
doc.Release();
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
mergeObject.DocName = doc.FileName;
|
|
@@ -803,7 +825,7 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
mergeObject.IsEvenPageIsEnabled = false;
|
|
|
}
|
|
|
mergeObject.SDKPageCount = doc.PageCount;
|
|
|
-
|
|
|
+
|
|
|
mergeObject.DocSize = CommonHelper.GetFileSize(mergeObject.FilePath);
|
|
|
|
|
|
//获取第一页缩略图
|
|
@@ -836,7 +858,30 @@ namespace PDF_Master.ViewModels.Dialog.ToolsDialogs
|
|
|
{
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- #endregion
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 未购买的用户 设置文件数量
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="filePath"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private int SetFilesLength(string[] filePath)
|
|
|
+ {
|
|
|
+ int sum = filePath.Length;
|
|
|
+ if (Settings.Default.UserDate.subscribestatus != 1 && sum >= 2)
|
|
|
+ {
|
|
|
+ if (MergeObjectlist.Count >= 1)
|
|
|
+ {
|
|
|
+ sum = 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sum = 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sum;
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion 公开方法
|
|
|
}
|
|
|
-}
|
|
|
+}
|