HomePageConverterDialogViewModel.cs 25 KB

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