HomePageHeaderFooterDialogViewModel.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. using ComPDFKit.PDFDocument;
  2. using PDF_Office.CustomControl;
  3. using PDF_Office.Helper;
  4. using PDF_Office.Model.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
  5. using PDF_Office.Model;
  6. using Prism.Commands;
  7. using Prism.Mvvm;
  8. using Prism.Regions;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Data;
  12. using System.Diagnostics;
  13. using System.IO;
  14. using System.Linq;
  15. using System.Windows;
  16. using System.Windows.Forms;
  17. using Prism.Events;
  18. using ComPDFKitViewer.PdfViewer;
  19. using PDF_Office.EventAggregators;
  20. using PDFSettings;
  21. using PDF_Office.Model.EditTools.HeaderFooter;
  22. using Prism.Services.Dialogs;
  23. namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageHeaderFooter
  24. {
  25. public class HomePageHeaderFooterDialogViewModel : BindableBase, INavigationAware
  26. {
  27. #region 参数和属性
  28. private List<string> fileNames;
  29. private CPDFDocument tempDocument;
  30. public string PageNumber = "";
  31. private CPDFHeaderFooter headerFooter;
  32. public IRegionManager headerFooterRegion;
  33. public IEventAggregator eventAggregator;
  34. public IDialogService dialogs;
  35. private CPDFViewer PDFViewer;
  36. public HeaderFooterInfo HeaderFooterInfo;
  37. private ViewContentViewModel viewContentViewModel;
  38. public string TemplateListName = "HomePageHeaderFooterTemplateListContent";
  39. public string CreateName = "HomePageHeaderFooterCreateContent";
  40. public string HeaderFooterType = "HomePageHeaderFooterType";
  41. private string _headerFooterSettingsRegionName;
  42. /// <summary>
  43. /// 属性设置Region
  44. /// </summary>
  45. public string HeaderFooterSettingsRegionName
  46. {
  47. get { return _headerFooterSettingsRegionName; }
  48. set { _headerFooterSettingsRegionName = value; }
  49. }
  50. private Visibility _headerFooterSettingsVisible = Visibility.Visible;
  51. /// <summary>
  52. /// 属性设置Region可见
  53. /// </summary>
  54. public Visibility HeaderFooterSettingsVisible
  55. {
  56. get { return _headerFooterSettingsVisible; }
  57. set { _headerFooterSettingsVisible = value; }
  58. }
  59. public List<int> fileNamesView = new List<int>();
  60. private int fileNamesIndex = 0;
  61. private int FileNameNumber = 0;
  62. private string headerFooterGridIsEnabled = "True";
  63. public string HeaderFooterGridIsEnabled
  64. {
  65. get
  66. {
  67. return headerFooterGridIsEnabled;
  68. }
  69. set
  70. {
  71. SetProperty(ref headerFooterGridIsEnabled, value);
  72. }
  73. }
  74. private string setHeaderFooterGridIsEnabled = "True";
  75. public string SetHeaderFooterGridIsEnabled
  76. {
  77. get
  78. {
  79. return setHeaderFooterGridIsEnabled;
  80. }
  81. set
  82. {
  83. SetProperty(ref setHeaderFooterGridIsEnabled, value);
  84. }
  85. }
  86. private DataTable pdfDataTable = new DataTable();
  87. public DataTable PDFDataTable
  88. {
  89. get { return pdfDataTable; }
  90. set
  91. {
  92. SetProperty(ref pdfDataTable, value);
  93. }
  94. }
  95. private DataTable pdfCurrentDataTable = new DataTable();
  96. public DataTable PDFCurrentDataTable
  97. {
  98. get { return pdfCurrentDataTable; }
  99. set
  100. {
  101. SetProperty(ref pdfCurrentDataTable, value);
  102. }
  103. }
  104. private string removeIsEnable = "False";
  105. public string RemoveIsEnable
  106. {
  107. get { return removeIsEnable; }
  108. set
  109. {
  110. SetProperty(ref removeIsEnable, value);
  111. }
  112. }
  113. private string selectFileName = "False";
  114. public string SelectFileName
  115. {
  116. get { return selectFileName; }
  117. set
  118. {
  119. SetProperty(ref selectFileName, value);
  120. }
  121. }
  122. private string headerFooterRegionName;
  123. public string HeaderFooterRegionName
  124. {
  125. get
  126. {
  127. return headerFooterRegionName;
  128. }
  129. set
  130. {
  131. SetProperty(ref headerFooterRegionName, value);
  132. }
  133. }
  134. private Visibility headerFooterVisible = Visibility.Collapsed;
  135. public Visibility HeaderFooterVisible
  136. {
  137. get { return headerFooterVisible; }
  138. set { SetProperty(ref headerFooterVisible, value); }
  139. }
  140. private Visibility addFileVisibility = Visibility.Hidden;
  141. public Visibility AddFileVisibility
  142. {
  143. get { return addFileVisibility; }
  144. set
  145. {
  146. SetProperty(ref addFileVisibility, value);
  147. RaisePropertyChanged();
  148. }
  149. }
  150. private string createGridSpan = "1";
  151. public string CreateGridSpan
  152. {
  153. get { return createGridSpan; }
  154. set
  155. {
  156. SetProperty(ref createGridSpan, value);
  157. RaisePropertyChanged();
  158. }
  159. }
  160. private Visibility createGridSpanVisibility = Visibility.Visible;
  161. public Visibility CreateGridSpanVisibility
  162. {
  163. get { return createGridSpanVisibility; }
  164. set
  165. {
  166. SetProperty(ref createGridSpanVisibility, value);
  167. RaisePropertyChanged();
  168. }
  169. }
  170. #endregion
  171. #region 委托声明
  172. public DelegateCommand ADDPDFCommand { get; set; }
  173. public DelegateCommand RemovePDFFileCommand { get; set; }
  174. public DelegateCommand CreateCommand { get; set; }
  175. public DelegateCommand ADDPDFFilesCommand { get; set; }
  176. #endregion
  177. public string Unicode = null;
  178. public HomePageHeaderFooterDialogViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, IDialogService dialogs)
  179. {
  180. this.eventAggregator = eventAggregator;
  181. this.headerFooterRegion = regionManager;
  182. this.dialogs = dialogs;
  183. HeaderFooterSettingsRegionName = Guid.NewGuid().ToString();
  184. Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
  185. PDFCurrentDataTable.Columns.Add("FilePageRangeText");
  186. PDFCurrentDataTable.Columns.Add("FilePageRangeSelectIndex");
  187. PDFCurrentDataTable.Columns.Add("IsEvenPageIsEnabled");
  188. PDFCurrentDataTable.Columns.Add("FileState");
  189. PDFDataTable.Columns.Add("FileName");
  190. PDFDataTable.Columns.Add("FilePageRangeText");
  191. PDFDataTable.Columns.Add("FilePageRangeSelectIndex");
  192. PDFDataTable.Columns.Add("IsEvenPageIsEnabled");
  193. PDFDataTable.Columns.Add("MaxPageRange");
  194. PDFDataTable.Columns.Add("FileSize");
  195. PDFDataTable.Columns.Add("FileState");
  196. ADDPDFCommand = new DelegateCommand(addpicture);
  197. ADDPDFFilesCommand = new DelegateCommand(addpicturefiles);
  198. RemovePDFFileCommand = new DelegateCommand(removepdffile);
  199. CreateCommand = new DelegateCommand(create);
  200. eventAggregator.GetEvent<EditBatesHeaderFooterTemplateItemEvent>().Subscribe(EditHeaderFooterTemplateItem, e => e.Unicode == Unicode && e.Type == HeaderFooterType);
  201. eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Subscribe(EnterTemplateListOrCreate, e => e.Unicode == Unicode);
  202. }
  203. #region 逻辑函数
  204. public void EditHeaderFooterTemplateItem(BatesHeaderFooterItemUnicode headerfooterItemunicode)
  205. {
  206. BatesHeaderFooterItem headerfooterItem = headerfooterItemunicode.Status;
  207. NavigationParameters param = new NavigationParameters();
  208. param.Add(ParameterNames.PDFViewer, PDFViewer);
  209. param.Add("HeaderFooterItem", headerfooterItem);
  210. headerFooterRegion.RequestNavigate(HeaderFooterSettingsRegionName, CreateName, param);
  211. HeaderFooterSettingsVisible = Visibility.Visible;
  212. CreateGridSpan = "2";
  213. CreateGridSpanVisibility = Visibility.Collapsed;
  214. }
  215. public void EnterTemplateListOrCreate(EnumTemplateListOrCreateUnicode enumTemplateListOrCreateunicode)
  216. {
  217. EnumTemplateListOrCreate enumTemplateListOrCreate = enumTemplateListOrCreateunicode.Status;
  218. if (enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
  219. {
  220. CreateGridSpan = "1";
  221. CreateGridSpanVisibility = Visibility.Visible;
  222. EnterSelectedContent(TemplateListName);
  223. }
  224. else
  225. {
  226. CreateGridSpan = "2";
  227. CreateGridSpanVisibility = Visibility.Collapsed;
  228. EnterSelectedContent(CreateName);
  229. }
  230. }
  231. public void EnterSelectedContent(string SelectedContentName)
  232. {
  233. NavigationParameters param = new NavigationParameters();
  234. param.Add(ParameterNames.PDFViewer, PDFViewer);
  235. param.Add("ViewModel", this);
  236. headerFooterRegion.RequestNavigate(HeaderFooterSettingsRegionName, SelectedContentName, param);
  237. HeaderFooterSettingsVisible = Visibility.Visible;
  238. }
  239. private void create()
  240. {
  241. updateListview("待确定");
  242. fileNamesIndex = 0;
  243. HeaderFooterGridIsEnabled = "False";
  244. foreach (var filename in fileNames)
  245. {
  246. FileInfo fileinfo = new FileInfo(filename);
  247. string OutputPath = fileinfo.DirectoryName;
  248. char[] enumerationSeparator = new char[] { ',' };
  249. char[] rangeSeparator = new char[] { '-' };
  250. List<int> PageIndexLists = new List<int>();
  251. CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
  252. if (document == null)
  253. {
  254. PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
  255. PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
  256. fileNamesIndex++;
  257. continue;
  258. }
  259. if (document.IsLocked)
  260. {
  261. DialogParameters value = new DialogParameters();
  262. value.Add(ParameterNames.PDFDocument, document);
  263. dialogs.ShowDialog(DialogNames.VerifyPassWordDialog, value, e =>
  264. {
  265. if (e.Result == ButtonResult.OK)
  266. {
  267. if (e.Parameters.ContainsKey(ParameterNames.PassWord) && e.Parameters.GetValue<string>(ParameterNames.PassWord) != null)
  268. {
  269. document.UnlockWithPassword(e.Parameters.GetValue<string>(ParameterNames.PassWord).ToString());
  270. }
  271. }
  272. });
  273. if (document.IsLocked)
  274. {
  275. //未成功解密文档时,释放Document对象,返回
  276. PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
  277. PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
  278. fileNamesIndex++;
  279. continue;
  280. }
  281. }
  282. CreateHeaderFooter(document);
  283. document.WriteToFilePath(CommonHelper.CreateFilePath(filename + "_HeaderFooter.pdf"));
  284. //if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
  285. //{ //TODO
  286. // Trace.WriteLine("输入不对");
  287. // MessageBoxEx.Show("输入不对");
  288. // return;
  289. //}
  290. document.Release();
  291. PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
  292. PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
  293. fileNamesIndex++;
  294. }
  295. HeaderFooterGridIsEnabled = "True";
  296. }
  297. public void CreateHeaderFooter(CPDFDocument document)
  298. {
  299. if (HeaderFooterInfo != null)
  300. {
  301. //document.(HeaderFooterInfo.TextData, HeaderFooterInfo.margin, HeaderFooterInfo.PageRange, HeaderFooterInfo.StarPagetNumber + 1);
  302. headerFooter = document.GetHeaderFooter();
  303. for (int i = 0; i < 6; i++)
  304. {
  305. headerFooter.SetText(i, HomePageEditHelper.ReverseDate(HeaderFooterInfo.TextData[i].text, document));
  306. headerFooter.SetFontName(i, HeaderFooterInfo.TextData[i].fontName);
  307. headerFooter.SetFontSize(i, HeaderFooterInfo.TextData[i].fontSize);
  308. headerFooter.SetTextColor(i, HeaderFooterInfo.TextData[i].Color);
  309. }
  310. headerFooter.SetPages(getFilePageRange(document, PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"].ToString(), PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"].ToString()));
  311. headerFooter.SetPageOffset(HeaderFooterInfo.StarPagetNumber + 1);
  312. headerFooter.SetMargin(HeaderFooterInfo.margin);
  313. headerFooter.Update();
  314. }
  315. }
  316. #endregion
  317. #region 批量处理逻辑函数
  318. /// <summary>
  319. /// 添加PDF文件
  320. /// </summary>
  321. private void addpicture()
  322. {
  323. FileNameNumber = fileNames.Count;
  324. System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
  325. dlg.Multiselect = true;
  326. dlg.Filter = "PDF|*.pdf;*.PDF;";
  327. if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  328. {
  329. fileNames.AddRange(dlg.FileNames.ToList());
  330. RemoveExcess(ref fileNames);
  331. SetHeaderFooterGridIsEnabled = "True";
  332. AddFileVisibility = Visibility.Collapsed;
  333. updateListview("待确定");
  334. }
  335. }
  336. public void addPDFFiles(string filename)
  337. {
  338. FileNameNumber = fileNames.Count;
  339. fileNames.Add(filename);
  340. RemoveExcess(ref fileNames);
  341. SetHeaderFooterGridIsEnabled = "True";
  342. AddFileVisibility = Visibility.Collapsed;
  343. updateListview("待确定");
  344. }
  345. /// <summary>
  346. /// 删除重复的文件
  347. /// </summary>
  348. public void RemoveExcess(ref List<string> Filenames)
  349. {
  350. List<string> filenames = new List<string>();
  351. foreach (var fileName in Filenames)
  352. {
  353. if (!filenames.Contains(fileName))
  354. {
  355. filenames.Add(fileName);
  356. }
  357. }
  358. Filenames.Clear();
  359. Filenames = filenames;
  360. }
  361. /// <summary>
  362. /// 添加PDF文件夹
  363. /// </summary>
  364. private void addpicturefiles()
  365. {
  366. FileNameNumber = fileNames.Count;
  367. FolderBrowserDialog dialog = new FolderBrowserDialog();
  368. dialog.Description = "请选择文件路径";
  369. if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  370. {
  371. string foldPath = dialog.SelectedPath;
  372. var apps = System.IO.Directory.GetFiles(foldPath);
  373. foreach (string app in apps)
  374. {
  375. var fi = new FileInfo(app);
  376. if (fi.Extension == ".pdf" || fi.Extension == ".PDF")
  377. {
  378. fileNames.Add(app);
  379. }
  380. }
  381. RemoveExcess(ref fileNames);
  382. updateListview("待确定");
  383. SetHeaderFooterGridIsEnabled = "True";
  384. AddFileVisibility = Visibility.Collapsed;
  385. }
  386. }
  387. /// <summary>
  388. /// 更新listview显示
  389. /// state 状态显示字符串
  390. /// </summary>
  391. public void updateListview(string state)
  392. {
  393. updateCurrentListview();
  394. DataTable pdfdatatable = new DataTable();
  395. pdfdatatable.Columns.Add("FileName");
  396. pdfdatatable.Columns.Add("FilePageRangeText");
  397. pdfdatatable.Columns.Add("FilePageRangeSelectIndex");
  398. pdfdatatable.Columns.Add("IsEvenPageIsEnabled");
  399. pdfdatatable.Columns.Add("MaxPageRange");
  400. pdfdatatable.Columns.Add("FileSize");
  401. pdfdatatable.Columns.Add("FileState");
  402. int datatableindex = 0;
  403. List<int> PageIndexLists = new List<int>();
  404. foreach (var fileName in fileNames)
  405. {
  406. string file_all = fileName;
  407. FileInfo f = new FileInfo(file_all);
  408. string file_size = (((float)f.Length) / 1024).ToString() + " K";
  409. if (!isEvenPage(fileName) && PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"].ToString() == "2")
  410. {
  411. PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"] = "0";
  412. }
  413. int pagecount = CPDFDocument.InitWithFilePath(fileName).PageCount;
  414. if (PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"].ToString() == "3" && !CommonHelper.GetPagesInRange(ref PageIndexLists, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"].ToString(), pagecount, new char[] { ',' }, new char[] { '-' }, true))
  415. {
  416. PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"] = "0";
  417. }
  418. pdfdatatable.Rows.Add(f.Name, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"], PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"], isEvenPage(fileName), pagecount, file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
  419. datatableindex++;
  420. }
  421. PDFDataTable = pdfdatatable;
  422. HomePageBatchProcessingDialogModel.FilePaths = fileNames;
  423. }
  424. /// <summary>
  425. /// 更新Currentlistview显示
  426. /// pagerangetext 自定义页面范围字符串 pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)isevenpageisenabled 偶数页状态 state 状态显示字符串
  427. /// </summary>
  428. public void updateCurrentListview(string pagerangetext = "1", string pagerangeselectindex = "0", bool isevenpageisenabled = true, string state = "待完成")
  429. {
  430. if (fileNames.Count >= FileNameNumber)
  431. {
  432. for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
  433. {
  434. PDFCurrentDataTable.Rows.Add(pagerangetext, pagerangeselectindex, isevenpageisenabled, state);
  435. }
  436. }
  437. else
  438. {
  439. Reverseorder(ref fileNamesView);
  440. foreach (int filenamesview in fileNamesView)
  441. {
  442. PDFCurrentDataTable.Rows.RemoveAt(filenamesview);
  443. }
  444. }
  445. }
  446. /// <summary>
  447. /// 更新Currentlistview显示
  448. /// pagerangetext 自定义页面范围字符串 pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
  449. /// </summary>
  450. public void updateFilesPageRange(string pagerangetext = "1", string pagerangeselectindex = "0")
  451. {
  452. for (int i = 0; fileNames.Count > i; i++)
  453. {
  454. PDFDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
  455. PDFDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
  456. PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
  457. PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
  458. }
  459. }
  460. /// <summary>
  461. /// 获取文件列表单个文件对应的页码范围
  462. /// document 文档对象 pagerangetext 自定义页面范围字符串 pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
  463. /// </summary>
  464. public string getFilePageRange(CPDFDocument document, string pagerangetext = "1", string pagerangeselectindex = "0")
  465. {
  466. string filePageRange = "1";
  467. EditToolsHelper.GetPageRange(int.Parse(pagerangeselectindex), document, ref filePageRange, pagerangetext);
  468. return filePageRange;
  469. }
  470. /// <summary>
  471. /// 判断是否关闭偶数页
  472. /// document 文档对象 )
  473. /// </summary>
  474. public bool isEvenPage(string filename)
  475. {
  476. CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
  477. bool isevenpage = false;
  478. if (document.PageCount > 1)
  479. {
  480. isevenpage = true;
  481. }
  482. document.Release();
  483. return isevenpage;
  484. }
  485. /// <summary>
  486. /// 逆序int类型集合
  487. /// </summary>
  488. public void Reverseorder(ref List<int> Numbers)
  489. {
  490. Numbers = Numbers.OrderBy(a => a).ToList();
  491. Numbers.Reverse();
  492. }
  493. /// <summary>
  494. /// 打开文件PDF
  495. /// </summary>
  496. public void openfiledialog()
  497. {
  498. foreach (int filenamesview in fileNamesView)
  499. {
  500. System.Diagnostics.Process.Start(fileNames[filenamesview]);
  501. }
  502. }
  503. /// <summary>
  504. /// 删除文件PDF
  505. /// </summary>
  506. public void removepdffile()
  507. {
  508. FileNameNumber = fileNames.Count;
  509. Reverseorder(ref fileNamesView);
  510. foreach (int filenamesview in fileNamesView)
  511. {
  512. //Trace.WriteLine(filenamesview);
  513. fileNames.Remove(fileNames[filenamesview]);
  514. }
  515. if (fileNames.Count < 1)
  516. {
  517. SetHeaderFooterGridIsEnabled = "False";
  518. AddFileVisibility = Visibility.Visible;
  519. }
  520. updateListview("待确定");
  521. }
  522. public void removepdffile(int index)
  523. {
  524. PDFCurrentDataTable.Rows.RemoveAt(index);
  525. fileNames.Remove(fileNames[index]);
  526. if (fileNames.Count < 1)
  527. {
  528. SetHeaderFooterGridIsEnabled = "False";
  529. AddFileVisibility = Visibility.Visible;
  530. }
  531. updateListview("待确定");
  532. }
  533. public void PDFFileCount()
  534. {
  535. if (fileNames.Count == 0)
  536. {
  537. SetHeaderFooterGridIsEnabled = "False";
  538. AddFileVisibility = Visibility.Visible;
  539. }
  540. else
  541. {
  542. SetHeaderFooterGridIsEnabled = "True";
  543. AddFileVisibility = Visibility.Collapsed;
  544. }
  545. }
  546. #endregion
  547. #region 构架行为
  548. public void OnNavigatedTo(NavigationContext navigationContext)
  549. {
  550. List<string> filepath = new List<string>();
  551. navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
  552. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  553. navigationContext.Parameters.TryGetValue<List<string>>(ParameterNames.FilePath, out filepath);
  554. if (filepath != null)
  555. {
  556. fileNames = filepath;
  557. PDFFileCount();
  558. CreateGridSpan = "1";
  559. CreateGridSpanVisibility = Visibility.Visible;
  560. updateListview("待确定");
  561. EnterSelectedContent(TemplateListName);
  562. }
  563. }
  564. public bool IsNavigationTarget(NavigationContext navigationContext)
  565. {
  566. return true;
  567. }
  568. public void OnNavigatedFrom(NavigationContext navigationContext)
  569. {
  570. }
  571. #endregion
  572. }
  573. }