|
@@ -18,6 +18,7 @@ using ComPDFKitViewer.PdfViewer;
|
|
|
using Prism.Events;
|
|
|
using PDF_Office.EventAggregators;
|
|
|
using PDFSettings;
|
|
|
+using ImTools;
|
|
|
|
|
|
namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates
|
|
|
{
|
|
@@ -49,6 +50,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
|
|
|
|
|
|
private int fileNamesIndex = 0;
|
|
|
|
|
|
+ private int FileNameNumber = 0;
|
|
|
+
|
|
|
private string _batesSettingsRegionName;
|
|
|
/// <summary>
|
|
|
/// 属性设置Region
|
|
@@ -105,6 +108,16 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private DataTable pdfCurrentDataTable = new DataTable();
|
|
|
+ public DataTable PDFCurrentDataTable
|
|
|
+ {
|
|
|
+ get { return pdfCurrentDataTable; }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ SetProperty(ref pdfCurrentDataTable, value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private string removeIsEnable = "False";
|
|
|
public string RemoveIsEnable
|
|
|
{
|
|
@@ -163,6 +176,9 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
|
|
|
this.batesRegion = batesRegion;
|
|
|
BatesSettingsRegionName = Guid.NewGuid().ToString();
|
|
|
Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
|
|
|
+ PDFCurrentDataTable.Columns.Add("FilePageRangeText");
|
|
|
+ PDFCurrentDataTable.Columns.Add("FilePageRangeSelectIndex");
|
|
|
+ PDFCurrentDataTable.Columns.Add("FileState");
|
|
|
PDFDataTable.Columns.Add("FileName");
|
|
|
PDFDataTable.Columns.Add("FilePageRangeText");
|
|
|
PDFDataTable.Columns.Add("FilePageRangeSelectIndex");
|
|
@@ -214,26 +230,30 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
|
|
|
BatesGridIsEnabled = "False";
|
|
|
foreach (var filename in fileNames)
|
|
|
{
|
|
|
- FileInfo fileinfo = new FileInfo(filename);
|
|
|
- string OutputPath = fileinfo.DirectoryName;
|
|
|
- char[] enumerationSeparator = new char[] { ',' };
|
|
|
- char[] rangeSeparator = new char[] { '-' };
|
|
|
- List<int> PageIndexLists = new List<int>();
|
|
|
- CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
|
|
|
- if (document == null)
|
|
|
- {
|
|
|
- PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
|
|
|
- { //TODO
|
|
|
- Trace.WriteLine("输入不对");
|
|
|
- MessageBoxEx.Show("输入不对");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- document.Release();
|
|
|
+ //FileInfo fileinfo = new FileInfo(filename);
|
|
|
+ //string OutputPath = fileinfo.DirectoryName;
|
|
|
+ //char[] enumerationSeparator = new char[] { ',' };
|
|
|
+ //char[] rangeSeparator = new char[] { '-' };
|
|
|
+ //List<int> PageIndexLists = new List<int>();
|
|
|
+ //CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
|
|
|
+ //if (document == null)
|
|
|
+ //{
|
|
|
+ // PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
|
|
|
+ // continue;
|
|
|
+ //}
|
|
|
+ //if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
|
|
|
+ //{ //TODO
|
|
|
+ // Trace.WriteLine("输入不对");
|
|
|
+ // MessageBoxEx.Show("输入不对");
|
|
|
+ // return;
|
|
|
+ //}
|
|
|
+
|
|
|
+ //document.Release();
|
|
|
+ PDFDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
|
|
|
PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
|
|
|
+ PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"] = "2";
|
|
|
+ PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"] = "2";
|
|
|
+ PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
|
|
|
fileNamesIndex++;
|
|
|
}
|
|
|
BatesGridIsEnabled = "True";
|
|
@@ -246,6 +266,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
|
|
|
/// </summary>
|
|
|
private void addpicture()
|
|
|
{
|
|
|
+ FileNameNumber = fileNames.Count;
|
|
|
System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
|
|
|
dlg.Multiselect = true;
|
|
|
dlg.Filter = "PDF|*.pdf;*.PDF;";
|
|
@@ -258,9 +279,12 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
|
|
|
updateListview("待确定");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ /// <summary>
|
|
|
+ /// 拖拽添加PDF文件
|
|
|
+ /// </summary>
|
|
|
public void addPDFFiles(string filename)
|
|
|
{
|
|
|
+ FileNameNumber = fileNames.Count;
|
|
|
fileNames.Add(filename);
|
|
|
RemoveExcess(ref fileNames);
|
|
|
SetBatesGridIsEnabled = "True";
|
|
@@ -290,6 +314,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
|
|
|
/// </summary>
|
|
|
private void addpicturefiles()
|
|
|
{
|
|
|
+ FileNameNumber = fileNames.Count;
|
|
|
FolderBrowserDialog dialog = new FolderBrowserDialog();
|
|
|
dialog.Description = "请选择文件路径";
|
|
|
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
@@ -318,22 +343,56 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
|
|
|
/// </summary>
|
|
|
public void updateListview(string state)
|
|
|
{
|
|
|
+ updateCurrentListview();
|
|
|
DataTable pdfdatatable = new DataTable();
|
|
|
pdfdatatable.Columns.Add("FileName");
|
|
|
+ pdfdatatable.Columns.Add("FilePageRangeText");
|
|
|
+ pdfdatatable.Columns.Add("FilePageRangeSelectIndex");
|
|
|
pdfdatatable.Columns.Add("FileSize");
|
|
|
pdfdatatable.Columns.Add("FileState");
|
|
|
+ int datatableindex = 0;
|
|
|
foreach (var fileName in fileNames)
|
|
|
{
|
|
|
string file_all = fileName;
|
|
|
FileInfo f = new FileInfo(file_all);
|
|
|
string file_size = (((float)f.Length) / 1024).ToString() + " K";
|
|
|
- pdfdatatable.Rows.Add(f.Name, file_size, state);
|
|
|
+
|
|
|
+ pdfdatatable.Rows.Add(f.Name, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"], PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"], file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
|
|
|
+ datatableindex++;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
PDFDataTable = pdfdatatable;
|
|
|
HomePageBatchProcessingDialogModel.FilePaths = fileNames;
|
|
|
|
|
|
}
|
|
|
/// <summary>
|
|
|
+ /// 更新Currentlistview显示
|
|
|
+ /// pagerangetext 自定义页面范围字符串 pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面) state 状态显示字符串
|
|
|
+ /// </summary>
|
|
|
+ public void updateCurrentListview(string pagerangetext = "1", string pagerangeselectindex = "0", string state = "待完成")
|
|
|
+ {
|
|
|
+ if (fileNames.Count >= FileNameNumber)
|
|
|
+ {
|
|
|
+ for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
|
|
|
+ {
|
|
|
+ PDFCurrentDataTable.Rows.Add(pagerangetext, pagerangeselectindex, state);
|
|
|
+ //PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
|
|
|
+ //PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
|
|
|
+ //PDFCurrentDataTable.Rows[i]["FileState"] = state;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Reverseorder(ref fileNamesView);
|
|
|
+ foreach (int filenamesview in fileNamesView)
|
|
|
+ {
|
|
|
+ PDFCurrentDataTable.Rows.RemoveAt(filenamesview);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
/// 逆序int类型集合
|
|
|
/// </summary>
|
|
|
public void Reverseorder(ref List<int> Numbers)
|
|
@@ -359,6 +418,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
|
|
|
/// </summary>
|
|
|
public void removepdffile()
|
|
|
{
|
|
|
+ FileNameNumber = fileNames.Count;
|
|
|
Reverseorder(ref fileNamesView);
|
|
|
foreach (int filenamesview in fileNamesView)
|
|
|
{
|
|
@@ -370,6 +430,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
|
|
|
SetBatesGridIsEnabled = "False";
|
|
|
AddFileVisibility = Visibility.Visible;
|
|
|
}
|
|
|
+
|
|
|
updateListview("待确定");
|
|
|
}
|
|
|
|
|
@@ -388,6 +449,8 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
#endregion
|
|
|
|
|
|
#region 构架行为
|
|
@@ -396,7 +459,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcess
|
|
|
List<string> filepath = new List<string>();
|
|
|
navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
|
|
|
navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
|
|
|
-
|
|
|
+
|
|
|
navigationContext.Parameters.TryGetValue<List<string>>(ParameterNames.FilePath, out filepath);
|
|
|
if (filepath != null)
|
|
|
{
|