|
@@ -22,6 +22,7 @@ using System.Collections.ObjectModel;
|
|
|
using System.Diagnostics;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
+using System.Threading;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Controls;
|
|
@@ -826,8 +827,11 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
|
if (isDiscryptied)
|
|
|
{
|
|
|
//先删除
|
|
|
- DoRemoveSelectedPages(indexList, false, true);
|
|
|
-
|
|
|
+ int flag = DoRemoveSelectedPages(indexList, false, true);
|
|
|
+ if (flag == -1)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (PDFViewer.Document.PageCount == 0)
|
|
|
{
|
|
|
index = 0;
|
|
@@ -2354,7 +2358,7 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
|
{
|
|
|
AlertsMessage alertsMessage = new AlertsMessage();
|
|
|
alertsMessage.ShowDialog("", App.MainPageLoader.GetString("PageEdit_DeleteAllPage"), App.ServiceLoader.GetString("Text_ok"));
|
|
|
- return index;
|
|
|
+ return -1;
|
|
|
}
|
|
|
}
|
|
|
bool isLast = false;
|
|
@@ -2391,7 +2395,7 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
|
if (!result)
|
|
|
{
|
|
|
ShowToast();
|
|
|
- return index;
|
|
|
+ return -1;
|
|
|
}
|
|
|
|
|
|
//文档层操作成功后再删除UI层
|
|
@@ -2534,7 +2538,7 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
|
IsLoading = Visibility.Collapsed;
|
|
|
}
|
|
|
|
|
|
- private void DoSplitPages(HomePageSplitDialogModel model)
|
|
|
+ private async void DoSplitPages(HomePageSplitDialogModel model)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
@@ -2561,6 +2565,7 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
|
{
|
|
|
Directory.CreateDirectory(directory);
|
|
|
}
|
|
|
+ App.mainWindowViewModel.ProcessCloseAction = PageSplitClear;
|
|
|
string filename = "";
|
|
|
int index = 0;
|
|
|
if (data.Mode == HomePageSplitDialogModel.SplitMode.AveragePages)
|
|
@@ -2574,6 +2579,12 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
|
selectedfile = data.FileName + " " + "1.pdf";
|
|
|
for (int i = 0; i < splitCount; i++)
|
|
|
{
|
|
|
+ App.mainWindowViewModel.Value = i;
|
|
|
+ await Task.Delay(50); // 模拟长时间操作
|
|
|
+ if (App.mainWindowViewModel.ProgressTitle == "Canceling")
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
int startNum = i * perPages + 1;
|
|
|
int endNum = Math.Min(PageCount, (i + 1) * perPages);
|
|
|
string range = startNum.ToString() + "-" + endNum.ToString();
|
|
@@ -2612,6 +2623,12 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
|
selectedfile = data.FileName + " " + "1.pdf";
|
|
|
for (int i = 0; i < docCount; i++)
|
|
|
{
|
|
|
+ App.mainWindowViewModel.Value = i;
|
|
|
+ await Task.Delay(50); // 模拟长时间操作
|
|
|
+ if (App.mainWindowViewModel.ProgressTitle == "Canceling")
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
int endNum = startNum + (avePages - 1);
|
|
|
if (i < remain) endNum++;
|
|
|
endNum = Math.Min(endNum, PageCount);
|
|
@@ -2640,11 +2657,20 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
|
else//自定义页码范围
|
|
|
{
|
|
|
string pageRange = "";
|
|
|
+ List<int> pageList1 = new List<int>();
|
|
|
if (data.PageMode == HomePageSplitDialogModel.PageRangeMode.OddPage)
|
|
|
{
|
|
|
int[] page = new int[(PageCount + 1) / 2];
|
|
|
+ index = page.Length;
|
|
|
+ ChatGTPAIHelper.SetIntProcess(true, "Splitting...", index, System.Windows.Visibility.Visible);
|
|
|
for (int i = 0; i < page.Length; i++)
|
|
|
{
|
|
|
+ App.mainWindowViewModel.Value = i;
|
|
|
+ await Task.Delay(50); // 模拟长时间操作
|
|
|
+ if (App.mainWindowViewModel.ProgressTitle == "Canceling")
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
page[i] = i * 2 + 1;
|
|
|
}
|
|
|
pageRange = string.Join(",", page);
|
|
@@ -2652,22 +2678,29 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
|
else if (data.PageMode == HomePageSplitDialogModel.PageRangeMode.EvenPage)
|
|
|
{
|
|
|
int[] page = new int[PageCount / 2];
|
|
|
+ index = page.Length;
|
|
|
+ ChatGTPAIHelper.SetIntProcess(true, "Splitting...", index, System.Windows.Visibility.Visible);
|
|
|
for (int i = 0; i < page.Length; i++)
|
|
|
{
|
|
|
+ App.mainWindowViewModel.Value = i;
|
|
|
+ await Task.Delay(50); // 模拟长时间操作
|
|
|
+ if (App.mainWindowViewModel.ProgressTitle == "Canceling")
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
page[i] = i * 2 + 2;
|
|
|
}
|
|
|
pageRange = string.Join(",", page);
|
|
|
}
|
|
|
else if (data.PageMode == HomePageSplitDialogModel.PageRangeMode.CustomPage)
|
|
|
{
|
|
|
+ ChatGTPAIHelper.SetIntProcess(true, "Splitting...", PageCount, System.Windows.Visibility.Visible);
|
|
|
pageRange = data.PageRange;
|
|
|
+ //如果是自定义输入页面范围的话,直接解析
|
|
|
+ CommonHelper.GetPagesInRange(ref pageList1, pageRange, PageCount, new char[] { ',' }, new char[] { '-' });
|
|
|
}
|
|
|
- List<int> pageList1 = new List<int>();
|
|
|
- //如果是自定义输入页面范围的话,直接解析
|
|
|
- CommonHelper.GetPagesInRange(ref pageList1, pageRange, PageCount, new char[] { ',' }, new char[] { '-' });
|
|
|
|
|
|
index = pageList1.Count;
|
|
|
- ChatGTPAIHelper.SetIntProcess(true, "Splitting...", index, System.Windows.Visibility.Visible);
|
|
|
|
|
|
#region //part1
|
|
|
|
|
@@ -2740,6 +2773,12 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void PageSplitClear()
|
|
|
+ {
|
|
|
+ App.mainWindowViewModel.ProgressTitle = "Canceling";
|
|
|
+ App.mainWindowViewModel.IsProcessVisible = System.Windows.Visibility.Collapsed;
|
|
|
+ }
|
|
|
+
|
|
|
private string GetFileName(HomePageSplitDialogModel model, int index)
|
|
|
{
|
|
|
string filename = "";
|