|
@@ -716,6 +716,32 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
|
$"Picture({Image})|{Image}|" +
|
|
|
$"Html({Html})|{Html}"
|
|
|
);
|
|
|
+
|
|
|
+ List<int> indexList = new List<int>();
|
|
|
+ for (int i = 0; i < PageEditItems.Count; i++)
|
|
|
+ {
|
|
|
+ if (PageEditItems[i].Selected)
|
|
|
+ {
|
|
|
+ indexList.Add(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //因为虚拟化 可能获取不到所有选中项的页码 需要结合选中项的集合判断一下
|
|
|
+ if (selectedPageList.Count > 0 && selectedPageList.Count > indexList.Count)
|
|
|
+ {
|
|
|
+ indexList = new List<int>();
|
|
|
+ for (int j = 0; j < selectedPageList.Count; j++)
|
|
|
+ {
|
|
|
+ indexList.Add(selectedPageList[j] - 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ indexList.Sort();
|
|
|
+ //全选页面 提示不能全选
|
|
|
+ if (indexList.Count > 0 && indexList.Count == PDFViewer.Document.PageCount)
|
|
|
+ {
|
|
|
+ AlertsMessage alertsMessage = new AlertsMessage();
|
|
|
+ alertsMessage.ShowDialog("", App.MainPageLoader.GetString("PageEdit_DeleteAllPage"), App.ServiceLoader.GetString("Text_ok"));
|
|
|
+ return;
|
|
|
+ }
|
|
|
if ((bool)dialog.ShowDialog())
|
|
|
{
|
|
|
//付费锁
|
|
@@ -730,33 +756,6 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
|
|
|
|
string fileName = GetInsertFromFile(dialog.FileName);
|
|
|
|
|
|
- List<int> indexList = new List<int>();
|
|
|
- for (int i = 0; i < PageEditItems.Count; i++)
|
|
|
- {
|
|
|
- if (PageEditItems[i].Selected)
|
|
|
- {
|
|
|
- indexList.Add(i);
|
|
|
- }
|
|
|
- }
|
|
|
- //因为虚拟化 可能获取不到所有选中项的页码 需要结合选中项的集合判断一下
|
|
|
- if (selectedPageList.Count > 0 && selectedPageList.Count > indexList.Count)
|
|
|
- {
|
|
|
- indexList = new List<int>();
|
|
|
- for (int j = 0; j < selectedPageList.Count; j++)
|
|
|
- {
|
|
|
- indexList.Add(selectedPageList[j] - 1);
|
|
|
- }
|
|
|
- }
|
|
|
- indexList.Sort();
|
|
|
-
|
|
|
- //foreach (var item in indexList)
|
|
|
- //{
|
|
|
- // if(listSelecedIndex + 1 <= item)
|
|
|
- // {
|
|
|
- // listSelecedIndex=item;
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
#region 历史版本
|
|
|
|
|
|
//从文件插入到指定位置
|
|
@@ -2299,7 +2298,7 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
|
//如果是自定义输入页面范围的话,直接解析
|
|
|
CommonHelper.GetPagesInRange(ref pageList1, pageRange, PageCount, new char[] { ',' }, new char[] { '-' });
|
|
|
|
|
|
- #region 方案一 //part1
|
|
|
+ #region //part1
|
|
|
|
|
|
selectedfile = "";
|
|
|
CPDFDocument saveDoc1 = CPDFDocument.CreateDocument();
|
|
@@ -2324,43 +2323,41 @@ namespace PDF_Master.ViewModels.PageEdit
|
|
|
saveDoc1.Release();
|
|
|
selectedfile = path1;
|
|
|
|
|
|
- #endregion 方案一 //part1
|
|
|
+ #endregion //part1
|
|
|
|
|
|
- #region 方案二 //Part2 奇数页、偶数页需要拆分成两个
|
|
|
+ #region 方案二 //Part2 除了选定之外的页面
|
|
|
|
|
|
- if (data.PageMode == HomePageSplitDialogModel.PageRangeMode.OddPage || data.PageMode == HomePageSplitDialogModel.PageRangeMode.EvenPage)
|
|
|
+ List<int> pageList2 = new List<int>();
|
|
|
+ for (int i = 1; i <= pdfViewer.Document.PageCount; i++)
|
|
|
+ {
|
|
|
+ if (!pageList1.Contains(i - 1))//pagelist1 存放的是index
|
|
|
+ pageList2.Add(i);
|
|
|
+ }
|
|
|
+ string pageRange2 = string.Join(",", pageList2);
|
|
|
+ CPDFDocument saveDoc2 = CPDFDocument.CreateDocument();
|
|
|
+ string filepath2 = /*data.FileName + " " + "2.pdf";*/ GetFileName(data, 1);
|
|
|
+ string path2 = /*Path.Combine(dialog.SelectedPath, filepath2);*/Path.Combine(directory, filepath2);
|
|
|
+ path2 = CommonHelper.CreateFilePath(path2);
|
|
|
+ bool result1 = saveDoc2.ImportPages(pdfViewer.Document, pageRange2);
|
|
|
+ if (!result1)
|
|
|
{
|
|
|
- List<int> pageList2 = new List<int>();
|
|
|
- for (int i = 1; i <= pdfViewer.Document.PageCount; i++)
|
|
|
- {
|
|
|
- if (!pageList1.Contains(i - 1))//pagelist1 存放的是index
|
|
|
- pageList2.Add(i);
|
|
|
- }
|
|
|
- string pageRange2 = string.Join(",", pageList2);
|
|
|
- CPDFDocument saveDoc2 = CPDFDocument.CreateDocument();
|
|
|
- string filepath2 = /*data.FileName + " " + "2.pdf";*/ GetFileName(data, 1);
|
|
|
- string path2 = /*Path.Combine(dialog.SelectedPath, filepath2);*/Path.Combine(directory, filepath2);
|
|
|
- path2 = CommonHelper.CreateFilePath(path2);
|
|
|
- bool result1 = saveDoc2.ImportPages(pdfViewer.Document, pageRange2);
|
|
|
- if (!result1)
|
|
|
- {
|
|
|
- saveDoc2.Release();
|
|
|
- ShowToast();
|
|
|
- return;
|
|
|
- }
|
|
|
- result1 = saveDoc2.WriteToFilePath(path2);
|
|
|
- if (!result1)
|
|
|
- {
|
|
|
- saveDoc2.Release();
|
|
|
- ShowToast();
|
|
|
- return;
|
|
|
- }
|
|
|
saveDoc2.Release();
|
|
|
- selectedfile = path2;
|
|
|
+ ShowToast();
|
|
|
+ return;
|
|
|
}
|
|
|
-
|
|
|
- #endregion 方案二 //Part2 奇数页、偶数页需要拆分成两个
|
|
|
+ result1 = saveDoc2.WriteToFilePath(path2);
|
|
|
+ if (!result1)
|
|
|
+ {
|
|
|
+ saveDoc2.Release();
|
|
|
+ ShowToast();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ saveDoc2.Release();
|
|
|
+ //selectedfile = path2;
|
|
|
}
|
|
|
+
|
|
|
+ #endregion 方案二 //Part2 除了选定之外的页面
|
|
|
+
|
|
|
//显示文件夹,并选中一个文件
|
|
|
Process.Start("explorer", "/select,\"" + selectedfile + "\"");
|
|
|
}
|