HomePageHeaderFooterDialogViewModel.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  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("FileSize");
  194. PDFDataTable.Columns.Add("FileState");
  195. ADDPDFCommand = new DelegateCommand(addpicture);
  196. ADDPDFFilesCommand = new DelegateCommand(addpicturefiles);
  197. RemovePDFFileCommand = new DelegateCommand(removepdffile);
  198. CreateCommand = new DelegateCommand(create);
  199. eventAggregator.GetEvent<EditBatesHeaderFooterTemplateItemEvent>().Subscribe(EditHeaderFooterTemplateItem, e => e.Unicode == Unicode && e.Type == HeaderFooterType);
  200. eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Subscribe(EnterTemplateListOrCreate, e => e.Unicode == Unicode);
  201. }
  202. #region 逻辑函数
  203. public void EditHeaderFooterTemplateItem(BatesHeaderFooterItemUnicode headerfooterItemunicode)
  204. {
  205. BatesHeaderFooterItem headerfooterItem = headerfooterItemunicode.Status;
  206. NavigationParameters param = new NavigationParameters();
  207. param.Add(ParameterNames.PDFViewer, PDFViewer);
  208. param.Add("HeaderFooterItem", headerfooterItem);
  209. headerFooterRegion.RequestNavigate(HeaderFooterSettingsRegionName, CreateName, param);
  210. HeaderFooterSettingsVisible = Visibility.Visible;
  211. CreateGridSpan = "2";
  212. CreateGridSpanVisibility = Visibility.Collapsed;
  213. }
  214. public void EnterTemplateListOrCreate(EnumTemplateListOrCreateUnicode enumTemplateListOrCreateunicode)
  215. {
  216. EnumTemplateListOrCreate enumTemplateListOrCreate = enumTemplateListOrCreateunicode.Status;
  217. if (enumTemplateListOrCreate == EnumTemplateListOrCreate.StatusTemplate)
  218. {
  219. CreateGridSpan = "1";
  220. CreateGridSpanVisibility = Visibility.Visible;
  221. EnterSelectedContent(TemplateListName);
  222. }
  223. else
  224. {
  225. CreateGridSpan = "2";
  226. CreateGridSpanVisibility = Visibility.Collapsed;
  227. EnterSelectedContent(CreateName);
  228. }
  229. }
  230. public void EnterSelectedContent(string SelectedContentName)
  231. {
  232. NavigationParameters param = new NavigationParameters();
  233. param.Add(ParameterNames.PDFViewer, PDFViewer);
  234. param.Add("ViewModel", this);
  235. headerFooterRegion.RequestNavigate(HeaderFooterSettingsRegionName, SelectedContentName, param);
  236. HeaderFooterSettingsVisible = Visibility.Visible;
  237. }
  238. private void create()
  239. {
  240. updateListview("待确定");
  241. fileNamesIndex = 0;
  242. HeaderFooterGridIsEnabled = "False";
  243. foreach (var filename in fileNames)
  244. {
  245. FileInfo fileinfo = new FileInfo(filename);
  246. string OutputPath = fileinfo.DirectoryName;
  247. char[] enumerationSeparator = new char[] { ',' };
  248. char[] rangeSeparator = new char[] { '-' };
  249. List<int> PageIndexLists = new List<int>();
  250. CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
  251. if (document == null)
  252. {
  253. PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
  254. PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
  255. fileNamesIndex++;
  256. continue;
  257. }
  258. if (document.IsLocked)
  259. {
  260. DialogParameters value = new DialogParameters();
  261. value.Add(ParameterNames.PDFDocument, document);
  262. dialogs.ShowDialog(DialogNames.VerifyPassWordDialog, value, e =>
  263. {
  264. if (e.Result == ButtonResult.OK)
  265. {
  266. if (e.Parameters.ContainsKey(ParameterNames.PassWord) && e.Parameters.GetValue<string>(ParameterNames.PassWord) != null)
  267. {
  268. document.UnlockWithPassword(e.Parameters.GetValue<string>(ParameterNames.PassWord).ToString());
  269. }
  270. }
  271. });
  272. if (document.IsLocked)
  273. {
  274. //未成功解密文档时,释放Document对象,返回
  275. PDFDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
  276. PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "文件出错";
  277. fileNamesIndex++;
  278. continue;
  279. }
  280. }
  281. CreateHeaderFooter(document);
  282. document.WriteToFilePath(CommonHelper.CreateFilePath(filename + "_HeaderFooter.pdf"));
  283. //if (!CommonHelper.GetPagesInRange(ref PageIndexLists, "1-" + document.PageCount.ToString(), document.PageCount, enumerationSeparator, rangeSeparator))
  284. //{ //TODO
  285. // Trace.WriteLine("输入不对");
  286. // MessageBoxEx.Show("输入不对");
  287. // return;
  288. //}
  289. document.Release();
  290. PDFDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
  291. PDFCurrentDataTable.Rows[fileNamesIndex]["FileState"] = "完成";
  292. fileNamesIndex++;
  293. }
  294. HeaderFooterGridIsEnabled = "True";
  295. }
  296. public void CreateHeaderFooter(CPDFDocument document)
  297. {
  298. if (HeaderFooterInfo != null)
  299. {
  300. //document.(HeaderFooterInfo.TextData, HeaderFooterInfo.margin, HeaderFooterInfo.PageRange, HeaderFooterInfo.StarPagetNumber + 1);
  301. headerFooter = document.GetHeaderFooter();
  302. for (int i = 0; i < 6; i++)
  303. {
  304. headerFooter.SetText(i, HomePageEditHelper.ReverseDate(HeaderFooterInfo.TextData[i].text, document));
  305. headerFooter.SetFontName(i, HeaderFooterInfo.TextData[i].fontName);
  306. headerFooter.SetFontSize(i, HeaderFooterInfo.TextData[i].fontSize);
  307. headerFooter.SetTextColor(i, HeaderFooterInfo.TextData[i].Color);
  308. }
  309. headerFooter.SetPages(getFilePageRange(document, PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeText"].ToString(), PDFCurrentDataTable.Rows[fileNamesIndex]["FilePageRangeSelectIndex"].ToString()));
  310. headerFooter.SetPageOffset(HeaderFooterInfo.StarPagetNumber + 1);
  311. headerFooter.SetMargin(HeaderFooterInfo.margin);
  312. headerFooter.Update();
  313. }
  314. }
  315. #endregion
  316. #region 批量处理逻辑函数
  317. /// <summary>
  318. /// 添加PDF文件
  319. /// </summary>
  320. private void addpicture()
  321. {
  322. FileNameNumber = fileNames.Count;
  323. System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
  324. dlg.Multiselect = true;
  325. dlg.Filter = "PDF|*.pdf;*.PDF;";
  326. if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  327. {
  328. fileNames.AddRange(dlg.FileNames.ToList());
  329. RemoveExcess(ref fileNames);
  330. SetHeaderFooterGridIsEnabled = "True";
  331. AddFileVisibility = Visibility.Collapsed;
  332. updateListview("待确定");
  333. }
  334. }
  335. public void addPDFFiles(string filename)
  336. {
  337. FileNameNumber = fileNames.Count;
  338. fileNames.Add(filename);
  339. RemoveExcess(ref fileNames);
  340. SetHeaderFooterGridIsEnabled = "True";
  341. AddFileVisibility = Visibility.Collapsed;
  342. updateListview("待确定");
  343. }
  344. /// <summary>
  345. /// 删除重复的文件
  346. /// </summary>
  347. public void RemoveExcess(ref List<string> Filenames)
  348. {
  349. List<string> filenames = new List<string>();
  350. foreach (var fileName in Filenames)
  351. {
  352. if (!filenames.Contains(fileName))
  353. {
  354. filenames.Add(fileName);
  355. }
  356. }
  357. Filenames.Clear();
  358. Filenames = filenames;
  359. }
  360. /// <summary>
  361. /// 添加PDF文件夹
  362. /// </summary>
  363. private void addpicturefiles()
  364. {
  365. FileNameNumber = fileNames.Count;
  366. FolderBrowserDialog dialog = new FolderBrowserDialog();
  367. dialog.Description = "请选择文件路径";
  368. if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  369. {
  370. string foldPath = dialog.SelectedPath;
  371. var apps = System.IO.Directory.GetFiles(foldPath);
  372. foreach (string app in apps)
  373. {
  374. var fi = new FileInfo(app);
  375. if (fi.Extension == ".pdf" || fi.Extension == ".PDF")
  376. {
  377. fileNames.Add(app);
  378. }
  379. }
  380. RemoveExcess(ref fileNames);
  381. updateListview("待确定");
  382. SetHeaderFooterGridIsEnabled = "True";
  383. AddFileVisibility = Visibility.Collapsed;
  384. }
  385. }
  386. /// <summary>
  387. /// 更新listview显示
  388. /// state 状态显示字符串
  389. /// </summary>
  390. public void updateListview(string state)
  391. {
  392. updateCurrentListview();
  393. DataTable pdfdatatable = new DataTable();
  394. pdfdatatable.Columns.Add("FileName");
  395. pdfdatatable.Columns.Add("FilePageRangeText");
  396. pdfdatatable.Columns.Add("FilePageRangeSelectIndex");
  397. pdfdatatable.Columns.Add("IsEvenPageIsEnabled");
  398. pdfdatatable.Columns.Add("FileSize");
  399. pdfdatatable.Columns.Add("FileState");
  400. int datatableindex = 0;
  401. List<int> PageIndexLists = new List<int>();
  402. foreach (var fileName in fileNames)
  403. {
  404. string file_all = fileName;
  405. FileInfo f = new FileInfo(file_all);
  406. string file_size = (((float)f.Length) / 1024).ToString() + " K";
  407. if (!isEvenPage(fileName) && PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"].ToString() == "2")
  408. {
  409. PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"] = "0";
  410. }
  411. if (PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"].ToString() == "3" && !CommonHelper.GetPagesInRange(ref PageIndexLists, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"].ToString(), CPDFDocument.InitWithFilePath(fileName).PageCount, new char[] { ',' }, new char[] { '-' }, true))
  412. {
  413. PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"] = "0";
  414. }
  415. pdfdatatable.Rows.Add(f.Name, PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeText"], PDFCurrentDataTable.Rows[datatableindex]["FilePageRangeSelectIndex"], isEvenPage(fileName), file_size, PDFCurrentDataTable.Rows[datatableindex]["FileState"]);
  416. datatableindex++;
  417. }
  418. PDFDataTable = pdfdatatable;
  419. HomePageBatchProcessingDialogModel.FilePaths = fileNames;
  420. }
  421. /// <summary>
  422. /// 更新Currentlistview显示
  423. /// pagerangetext 自定义页面范围字符串 pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)isevenpageisenabled 偶数页状态 state 状态显示字符串
  424. /// </summary>
  425. public void updateCurrentListview(string pagerangetext = "1", string pagerangeselectindex = "0", bool isevenpageisenabled = true, string state = "待完成")
  426. {
  427. if (fileNames.Count >= FileNameNumber)
  428. {
  429. for (int i = 0; fileNames.Count - FileNameNumber > i; i++)
  430. {
  431. PDFCurrentDataTable.Rows.Add(pagerangetext, pagerangeselectindex, isevenpageisenabled, state);
  432. }
  433. }
  434. else
  435. {
  436. Reverseorder(ref fileNamesView);
  437. foreach (int filenamesview in fileNamesView)
  438. {
  439. PDFCurrentDataTable.Rows.RemoveAt(filenamesview);
  440. }
  441. }
  442. }
  443. /// <summary>
  444. /// 更新Currentlistview显示
  445. /// pagerangetext 自定义页面范围字符串 pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
  446. /// </summary>
  447. public void updateFilesPageRange(string pagerangetext = "1", string pagerangeselectindex = "0")
  448. {
  449. for (int i = 0; fileNames.Count > i; i++)
  450. {
  451. PDFDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
  452. PDFDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
  453. PDFCurrentDataTable.Rows[i]["FilePageRangeText"] = pagerangetext;
  454. PDFCurrentDataTable.Rows[i]["FilePageRangeSelectIndex"] = pagerangeselectindex;
  455. }
  456. }
  457. /// <summary>
  458. /// 获取文件列表单个文件对应的页码范围
  459. /// document 文档对象 pagerangetext 自定义页面范围字符串 pagerangeselectindex combobox下拉索引(0全部页面 1奇数页 2偶数页 3自定义页面)
  460. /// </summary>
  461. public string getFilePageRange(CPDFDocument document, string pagerangetext = "1", string pagerangeselectindex = "0")
  462. {
  463. string filePageRange = "1";
  464. EditToolsHelper.GetPageRange(int.Parse(pagerangeselectindex), document, ref filePageRange, pagerangetext);
  465. return filePageRange;
  466. }
  467. /// <summary>
  468. /// 判断是否关闭偶数页
  469. /// document 文档对象 )
  470. /// </summary>
  471. public bool isEvenPage(string filename)
  472. {
  473. CPDFDocument document = CPDFDocument.InitWithFilePath(filename);
  474. bool isevenpage = false;
  475. if (document.PageCount > 1)
  476. {
  477. isevenpage = true;
  478. }
  479. document.Release();
  480. return isevenpage;
  481. }
  482. /// <summary>
  483. /// 逆序int类型集合
  484. /// </summary>
  485. public void Reverseorder(ref List<int> Numbers)
  486. {
  487. Numbers = Numbers.OrderBy(a => a).ToList();
  488. Numbers.Reverse();
  489. }
  490. /// <summary>
  491. /// 打开文件PDF
  492. /// </summary>
  493. public void openfiledialog()
  494. {
  495. foreach (int filenamesview in fileNamesView)
  496. {
  497. System.Diagnostics.Process.Start(fileNames[filenamesview]);
  498. }
  499. }
  500. /// <summary>
  501. /// 删除文件PDF
  502. /// </summary>
  503. public void removepdffile()
  504. {
  505. FileNameNumber = fileNames.Count;
  506. Reverseorder(ref fileNamesView);
  507. foreach (int filenamesview in fileNamesView)
  508. {
  509. //Trace.WriteLine(filenamesview);
  510. fileNames.Remove(fileNames[filenamesview]);
  511. }
  512. if (fileNames.Count < 1)
  513. {
  514. SetHeaderFooterGridIsEnabled = "False";
  515. AddFileVisibility = Visibility.Visible;
  516. }
  517. updateListview("待确定");
  518. }
  519. public void removepdffile(int index)
  520. {
  521. PDFCurrentDataTable.Rows.RemoveAt(index);
  522. fileNames.Remove(fileNames[index]);
  523. if (fileNames.Count < 1)
  524. {
  525. SetHeaderFooterGridIsEnabled = "False";
  526. AddFileVisibility = Visibility.Visible;
  527. }
  528. updateListview("待确定");
  529. }
  530. public void PDFFileCount()
  531. {
  532. if (fileNames.Count == 0)
  533. {
  534. SetHeaderFooterGridIsEnabled = "False";
  535. AddFileVisibility = Visibility.Visible;
  536. }
  537. else
  538. {
  539. SetHeaderFooterGridIsEnabled = "True";
  540. AddFileVisibility = Visibility.Collapsed;
  541. }
  542. }
  543. #endregion
  544. #region 构架行为
  545. public void OnNavigatedTo(NavigationContext navigationContext)
  546. {
  547. List<string> filepath = new List<string>();
  548. navigationContext.Parameters.TryGetValue<ViewContentViewModel>(ParameterNames.ViewContentViewModel, out viewContentViewModel);
  549. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  550. navigationContext.Parameters.TryGetValue<List<string>>(ParameterNames.FilePath, out filepath);
  551. if (filepath != null)
  552. {
  553. fileNames = filepath;
  554. PDFFileCount();
  555. CreateGridSpan = "1";
  556. CreateGridSpanVisibility = Visibility.Visible;
  557. updateListview("待确定");
  558. EnterSelectedContent(TemplateListName);
  559. }
  560. }
  561. public bool IsNavigationTarget(NavigationContext navigationContext)
  562. {
  563. return true;
  564. }
  565. public void OnNavigatedFrom(NavigationContext navigationContext)
  566. {
  567. }
  568. #endregion
  569. }
  570. }