HomePageBatesCreateContentViewModel.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. using ComPDFKitViewer.PdfViewer;
  2. using PDF_Office.EventAggregators;
  3. using PDF_Office.Helper;
  4. using PDF_Office.Model.EditTools.Bates;
  5. using PDF_Office.Model;
  6. using PDF_Office.Properties;
  7. using PDFSettings;
  8. using Prism.Commands;
  9. using Prism.Events;
  10. using Prism.Mvvm;
  11. using Prism.Regions;
  12. using System;
  13. using System.Collections.Generic;
  14. using System.IO;
  15. using System.Linq;
  16. using System.Windows.Media;
  17. using System.Windows;
  18. namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageBates
  19. {
  20. public class HomePageBatesCreateContentViewModel : BindableBase, INavigationAware
  21. {
  22. private CPDFViewer PDFViewer;
  23. public BatesInfo BatesInfo = new BatesInfo();
  24. public BatesHeaderFooterItem TemplateBatesItem;
  25. public enum EnumCreateOrEdit
  26. {
  27. None,
  28. StatusCreate,
  29. StatusEdit
  30. }
  31. private List<string> _fontNameList = new List<string>();
  32. public List<string> FontNameList
  33. {
  34. get { return _fontNameList; }
  35. set
  36. {
  37. SetProperty(ref _fontNameList, value);
  38. }
  39. }
  40. private void InitFontNameList()
  41. {
  42. FontNameList.Clear();
  43. FontNameList.Add("Courier");
  44. FontNameList.Add("Courier-Bold");
  45. FontNameList.Add("Courier-Oblique");
  46. FontNameList.Add("Courier-BoldOblique");
  47. FontNameList.Add("Helvetica");
  48. FontNameList.Add("Helvetica-Bold");
  49. FontNameList.Add("Helvetica-Oblique");
  50. FontNameList.Add("Helvetica-BoldOblique");
  51. FontNameList.Add("Times-Roman");
  52. FontNameList.Add("Times-Bold");
  53. FontNameList.Add("Times-Italic");
  54. FontNameList.Add("Times-BoldItalic");
  55. }
  56. private int _fontNameSelectedIndex = 0;
  57. public int FontNameSelectedIndex
  58. {
  59. get { return _fontNameSelectedIndex; }
  60. set
  61. {
  62. SetProperty(ref _fontNameSelectedIndex, value);
  63. SetFontName(FontNameSelectedIndex);
  64. }
  65. }
  66. private List<string> _fontSizeList = new List<string>();
  67. public List<string> FontSizeList
  68. {
  69. get { return _fontSizeList; }
  70. set
  71. {
  72. SetProperty(ref _fontSizeList, value);
  73. }
  74. }
  75. private void InitFontSizeList()
  76. {
  77. FontSizeList.Clear();
  78. for (int temp = 10; temp <= 15; temp += 1)
  79. {
  80. FontSizeList.Add(temp.ToString() + "pt");
  81. }
  82. }
  83. private int _fontSizeSelectedIndex = 0;
  84. public int FontSizeSelectedIndex
  85. {
  86. get { return _fontSizeSelectedIndex; }
  87. set
  88. {
  89. SetProperty(ref _fontSizeSelectedIndex, value);
  90. SetFontSize(FontSizeSelectedIndex);
  91. }
  92. }
  93. private List<string> _starPagetNumberList = new List<string>();
  94. public List<string> StarPagetNumberList
  95. {
  96. get { return _starPagetNumberList; }
  97. set
  98. {
  99. SetProperty(ref _starPagetNumberList, value);
  100. }
  101. }
  102. private void InitStarPagetNumberList()
  103. {
  104. StarPagetNumberList.Clear();
  105. for (int temp = 10; temp <= 15; temp += 1)
  106. {
  107. StarPagetNumberList.Add(temp.ToString());
  108. }
  109. }
  110. private int _starPagetNumberIndex = 0;
  111. public int StarPagetNumberIndex
  112. {
  113. get { return _starPagetNumberIndex; }
  114. set
  115. {
  116. SetProperty(ref _starPagetNumberIndex, value);
  117. SetStarPagetNumber(StarPagetNumberIndex);
  118. }
  119. }
  120. public string _pageRangeText = "0";
  121. public string PageRangeText
  122. {
  123. get { return _pageRangeText; }
  124. set
  125. {
  126. _pageRangeText = value;
  127. //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BatesInfo.PageRange, PageRangeText);
  128. }
  129. }
  130. private int _pageRangeSelectIndex = 0;
  131. public int PageRangeSelectIndex
  132. {
  133. get { return _pageRangeSelectIndex; }
  134. set
  135. {
  136. SetProperty(ref _pageRangeSelectIndex, value);
  137. BatesInfo.PageRangeIndex = PageRangeSelectIndex;
  138. //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BatesInfo.PageRange, PageRangeText);
  139. }
  140. }
  141. private SolidColorBrush _solidColorBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
  142. public SolidColorBrush SolidColorBrush
  143. {
  144. get
  145. {
  146. return _solidColorBrush;
  147. }
  148. set
  149. {
  150. SetProperty(ref _solidColorBrush, value);
  151. }
  152. }
  153. private Color _stringColor = Color.FromArgb(0xFF, 0xFF, 0x00, 0x00);
  154. public Color StringColor
  155. {
  156. get
  157. {
  158. return _stringColor;
  159. }
  160. set
  161. {
  162. SetProperty(ref _stringColor, value);
  163. SolidColorBrush = new SolidColorBrush(StringColor);
  164. for (int i = 0; i <= 5; i++)
  165. {
  166. BatesInfo.TextData[i].Color = EditToolsHelper.ConvertColor(value);
  167. }
  168. }
  169. }
  170. private EnumCreateOrEdit _createOrEdit;
  171. public EnumCreateOrEdit CreateOrEdit
  172. {
  173. get { return _createOrEdit; }
  174. set
  175. {
  176. _createOrEdit = value;
  177. if (value == EnumCreateOrEdit.StatusEdit)
  178. {
  179. EditBaseVisible = Visibility.Visible;
  180. CreateBaseVisible = Visibility.Collapsed;
  181. }
  182. else if (value == EnumCreateOrEdit.StatusCreate)
  183. {
  184. CreateBaseVisible = Visibility.Visible;
  185. EditBaseVisible = Visibility.Collapsed;
  186. }
  187. }
  188. }
  189. private Visibility _createBaseVisible;
  190. public Visibility CreateBaseVisible
  191. {
  192. get => _createBaseVisible;
  193. set => SetProperty(ref _createBaseVisible, value);
  194. }
  195. private Visibility _editBaseVisible;
  196. public Visibility EditBaseVisible
  197. {
  198. get => _editBaseVisible;
  199. set => SetProperty(ref _editBaseVisible, value);
  200. }
  201. private string _marginTopValue = "3";
  202. public string MarginTopValue
  203. {
  204. get { return _marginTopValue; }
  205. set
  206. {
  207. SetProperty(ref _marginTopValue, value);
  208. bool ValueEQ = true;
  209. if (BatesInfo.margin[1] == float.Parse(MarginTopValue))
  210. {
  211. ValueEQ = false;
  212. }
  213. BatesInfo.margin[1] = float.Parse(MarginTopValue);
  214. if (ValueEQ)
  215. {
  216. }
  217. }
  218. }
  219. private string _marginDownValue = "3";
  220. public string MarginDownValue
  221. {
  222. get { return _marginDownValue; }
  223. set
  224. {
  225. SetProperty(ref _marginDownValue, value);
  226. bool ValueEQ = true;
  227. if (BatesInfo.margin[3] == float.Parse(MarginTopValue))
  228. {
  229. ValueEQ = false;
  230. }
  231. BatesInfo.margin[3] = float.Parse(MarginDownValue);
  232. if (ValueEQ)
  233. {
  234. }
  235. }
  236. }
  237. private string _marginLeftValue = "3";
  238. public string MarginLeftValue
  239. {
  240. get { return _marginLeftValue; }
  241. set
  242. {
  243. SetProperty(ref _marginLeftValue, value);
  244. bool ValueEQ = true;
  245. if (BatesInfo.margin[0] == float.Parse(MarginTopValue))
  246. {
  247. ValueEQ = false;
  248. }
  249. BatesInfo.margin[0] = float.Parse(MarginLeftValue);
  250. if (ValueEQ)
  251. {
  252. }
  253. }
  254. }
  255. private string _marginRightValue = "3";
  256. public string MarginRightValue
  257. {
  258. get { return _marginRightValue; }
  259. set
  260. {
  261. SetProperty(ref _marginRightValue, value);
  262. bool ValueEQ = true;
  263. if (BatesInfo.margin[2] == float.Parse(MarginTopValue))
  264. {
  265. ValueEQ = false;
  266. }
  267. if (ValueEQ)
  268. {
  269. BatesInfo.margin[2] = float.Parse(MarginRightValue);
  270. }
  271. }
  272. }
  273. private string _digitNumberValue = "1";
  274. public string DigitNumberValue
  275. {
  276. get { return _digitNumberValue; }
  277. set
  278. {
  279. SetProperty(ref _digitNumberValue, value);
  280. BatesInfo.DigitNumber = int.Parse(DigitNumberValue);
  281. }
  282. }
  283. private string _textValue = "";
  284. public string TextValue
  285. {
  286. get { return _textValue; }
  287. set
  288. {
  289. SetProperty(ref _textValue, value);
  290. }
  291. }
  292. private string _prefixTextValue = "";
  293. public string PrefixTextValue
  294. {
  295. get { return _prefixTextValue; }
  296. set
  297. {
  298. _prefixTextValue = value;
  299. }
  300. }
  301. private string _surfixTextValue = "";
  302. public string SurfixTextValue
  303. {
  304. get { return _surfixTextValue; }
  305. set
  306. {
  307. _surfixTextValue = value;
  308. }
  309. }
  310. public int GetLocationIndex = 0;
  311. private Dictionary<string, string> _getTextValueFromNumber = new Dictionary<string, string>();
  312. public Dictionary<string, string> GetTextValueFromNumber
  313. {
  314. get { return _getTextValueFromNumber; }
  315. set
  316. {
  317. _getTextValueFromNumber = value;
  318. }
  319. }
  320. public IEventAggregator eventAggregator;
  321. public DelegateCommand<object> ChangeLocationCommand { get; set; }
  322. public DelegateCommand EnterTemplateListCommand { get; set; }
  323. public DelegateCommand SaveToTemplateListCommand { get; set; }
  324. public DelegateCommand SaveToCurrentTemplateListCommand { get; set; }
  325. public DelegateCommand<object> SelectedColorChangedCommand { get; set; }
  326. public DelegateCommand<object> TextValueChangedCommand { get; set; }
  327. public DelegateCommand ADDBatesCommand { get; set; }
  328. public string Unicode = null;
  329. public HomePageBatesCreateContentViewModel(IEventAggregator eventAggregator)
  330. {
  331. this.eventAggregator = eventAggregator;
  332. Unicode = App.mainWindowViewModel.SelectedItem.Unicode;
  333. for (int i = 0; i <= 5; i++)
  334. {
  335. BatesInfo.TextData[i].Color = EditToolsHelper.ConvertColor(Color.FromArgb(0xFF, 0xFF, 0x00, 0x00));
  336. }
  337. InitList();
  338. InitBatesInfo();
  339. ChangeLocationCommand = new DelegateCommand<object>(ChangeLocation);
  340. SelectedColorChangedCommand = new DelegateCommand<object>(ChangedColor);
  341. EnterTemplateListCommand = new DelegateCommand(EnterTemplateList);
  342. SaveToTemplateListCommand = new DelegateCommand(SaveToTemplateList);
  343. SaveToCurrentTemplateListCommand = new DelegateCommand(SaveToCurrentTemplateList);
  344. TextValueChangedCommand = new DelegateCommand<object>(TextValueChanged);
  345. ADDBatesCommand = new DelegateCommand(ADDBates);
  346. }
  347. private void InitList()
  348. {
  349. InitFontNameList();
  350. InitFontSizeList();
  351. InitStarPagetNumberList();
  352. InitLocationButtonMatrix();
  353. }
  354. private void InitLocationButtonMatrix()
  355. {
  356. GetTextValueFromNumber.Clear();
  357. for (var temp = 0; temp <= 5; temp++)
  358. {
  359. GetTextValueFromNumber.Add(temp.ToString(), temp.ToString());
  360. }
  361. }
  362. private void InitBatesInfo()
  363. {
  364. for (int i = 0; i <= 5; i++)
  365. {
  366. BatesInfo.TextData[i].text = GetTextValueFromNumber[i.ToString()];
  367. }
  368. BatesInfo.margin[0] = float.Parse(MarginTopValue);
  369. BatesInfo.margin[1] = float.Parse(MarginRightValue);
  370. BatesInfo.margin[2] = float.Parse(MarginDownValue);
  371. BatesInfo.margin[3] = float.Parse(MarginLeftValue);
  372. BatesInfo.Prefix = PrefixTextValue;
  373. BatesInfo.Suffix = SurfixTextValue;
  374. BatesInfo.DigitNumber = int.Parse(DigitNumberValue);
  375. SetFontName(FontNameSelectedIndex);
  376. SetFontSize(FontSizeSelectedIndex);
  377. SetStarPagetNumber(StarPagetNumberIndex);
  378. StringColor = Color.FromArgb(0xFF, 0xFF, 0x00, 0x00);
  379. }
  380. private void SetFontName(int Index)
  381. {
  382. for (int i = 0; i <= 5; i++) { BatesInfo.TextData[i].fontName = FontNameList[Index]; }
  383. }
  384. private void SetFontSize(int Index)
  385. {
  386. for (int i = 0; i <= 5; i++) { BatesInfo.TextData[i].fontSize = (Index + 7) * 1.33f; }
  387. }
  388. private void SetStarPagetNumber(int Index)
  389. {
  390. BatesInfo.StarPagetNumber = Index;
  391. }
  392. public void ChangeLocation(object e)
  393. {
  394. string args = e as string;
  395. if (args != null)
  396. {
  397. GetLocationIndex = int.Parse(args);
  398. TextValue = GetTextValueFromNumber[args];
  399. }
  400. }
  401. private void ChangedColor(object obj)
  402. {
  403. if (obj != null)
  404. {
  405. var colorValue = (Color)obj;
  406. if (colorValue != null)
  407. {
  408. StringColor = colorValue;
  409. }
  410. }
  411. }
  412. public void EnterTemplateList()
  413. {
  414. this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode { Unicode = Unicode, Status = EnumTemplateListOrCreate.StatusTemplate });
  415. }
  416. public void SaveToTemplateList()
  417. {
  418. SaveCurrentTemplate();
  419. }
  420. public void SaveToCurrentTemplateList()
  421. {
  422. ConfirmEditBackgroundTemplateItem();
  423. }
  424. private void TextValueChanged(object obj)
  425. {
  426. if (obj != null)
  427. {
  428. var textValue = obj as System.Windows.Controls.TextBox;
  429. if (textValue != null)
  430. {
  431. bool TextEQ = true;
  432. switch (textValue.Name)
  433. {
  434. case "TextValueTextBox":
  435. if (GetTextValueFromNumber[GetLocationIndex.ToString()] == textValue.Text)
  436. {
  437. TextEQ = false;
  438. }
  439. GetTextValueFromNumber[GetLocationIndex.ToString()] = textValue.Text;
  440. BatesInfo.TextData[GetLocationIndex].text = GetTextValueFromNumber[GetLocationIndex.ToString()];
  441. break;
  442. case "PrefixTextValueTextBox":
  443. if (BatesInfo.Prefix == textValue.Text)
  444. {
  445. TextEQ = false;
  446. }
  447. BatesInfo.Prefix = textValue.Text;
  448. break;
  449. case "SuffixTextValueTextBox":
  450. if (BatesInfo.Suffix == textValue.Text)
  451. {
  452. TextEQ = false;
  453. }
  454. BatesInfo.Suffix = textValue.Text;
  455. break;
  456. default:
  457. break;
  458. }
  459. if (TextEQ)
  460. {
  461. }
  462. }
  463. }
  464. }
  465. public void ADDBates()
  466. {
  467. if (PrefixTextValue == "" || SurfixTextValue == "")
  468. {
  469. if (SurfixTextValue == "" && PrefixTextValue == "")
  470. {
  471. GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + "#" + DigitNumberValue + "#" + (StarPagetNumberIndex + 1).ToString() + ">>";
  472. }
  473. else if (SurfixTextValue == "")
  474. {
  475. GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + "#" + DigitNumberValue + "#" + (StarPagetNumberIndex + 1).ToString() + "#" + PrefixTextValue + ">>";
  476. }
  477. else
  478. {
  479. GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + "#" + DigitNumberValue + "#" + (StarPagetNumberIndex + 1).ToString() + "#" + "#" + SurfixTextValue + ">>";
  480. }
  481. }
  482. else
  483. {
  484. GetTextValueFromNumber[GetLocationIndex.ToString()] = GetTextValueFromNumber[GetLocationIndex.ToString()] + "<<" + "#" + DigitNumberValue + "#" + (StarPagetNumberIndex + 1).ToString() + "#" + PrefixTextValue + "#" + SurfixTextValue + ">>";
  485. }
  486. BatesInfo.TextData[GetLocationIndex].text = GetTextValueFromNumber[GetLocationIndex.ToString()];
  487. }
  488. public void ConvertInfoToItem(ref BatesHeaderFooterItem batesItem, BatesInfo batesInfo)
  489. {
  490. batesItem.TextData = batesInfo.TextData;
  491. batesItem.DigitNumber = batesInfo.DigitNumber;
  492. batesItem.ItemName = batesInfo.ItemName;
  493. batesItem.Prefix = batesInfo.Prefix;
  494. batesItem.Suffix = batesInfo.Suffix;
  495. batesItem.StarPagetNumber = batesInfo.StarPagetNumber;
  496. batesItem.margin = batesInfo.margin;
  497. batesItem.PageRange = batesInfo.PageRange;
  498. batesItem.PageRangeIndex = batesInfo.PageRangeIndex;
  499. }
  500. public void ConvertItemToInfo(BatesHeaderFooterItem batesItem, ref BatesInfo batesInfo)
  501. {
  502. batesInfo.TextData = batesItem.TextData;
  503. batesInfo.ItemName = batesItem.ItemName;
  504. batesInfo.DigitNumber = batesItem.DigitNumber;
  505. batesInfo.Prefix = batesItem.Prefix;
  506. batesInfo.Suffix = batesItem.Suffix;
  507. batesInfo.StarPagetNumber = batesItem.StarPagetNumber;
  508. batesInfo.margin = batesItem.margin;
  509. batesInfo.PageRangeIndex = batesItem.PageRangeIndex;
  510. //EditToolsHelper.GetPageRange(batesInfo.PageRangeIndex, PDFViewer.Document, ref batesInfo.PageRange, batesItem.PageRange);
  511. }
  512. public void SaveCurrentTemplate()
  513. {
  514. var batesItem = new BatesHeaderFooterItem();
  515. ConvertInfoToItem(ref batesItem, BatesInfo);
  516. batesItem.ItemName += Settings.Default.BatesTemplateList.Count().ToString();
  517. try
  518. {
  519. //创建缓存文件夹
  520. string folderPath = Path.Combine(App.CurrentPath, "Bates");
  521. //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
  522. //保险措施(猜测)
  523. if (File.Exists(folderPath))
  524. {
  525. File.Delete(folderPath);
  526. }
  527. DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
  528. if (!tempfolder.Exists)
  529. {
  530. tempfolder.Create();
  531. }
  532. //预览图缓存
  533. string saveName = Guid.NewGuid().ToString();
  534. string savePath = Path.Combine(folderPath, saveName);
  535. Settings.Default.BatesTemplateList.Add(batesItem);
  536. Settings.Default.Save();
  537. }
  538. catch
  539. {
  540. }
  541. this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
  542. {
  543. Unicode = Unicode,
  544. Status = EnumTemplateListOrCreate.StatusTemplate
  545. });
  546. }
  547. public void ConfirmEditBackgroundTemplateItem()
  548. {
  549. var batesItem = new BatesHeaderFooterItem();
  550. ConvertInfoToItem(ref batesItem, BatesInfo);
  551. try
  552. {
  553. //创建缓存文件夹
  554. string folderPath = Path.Combine(App.CurrentPath, "Background");
  555. //有可能因为其他原因存在同名文件,导致创建文件夹失败,需要先删除同名文件
  556. //保险措施(猜测)
  557. if (File.Exists(folderPath))
  558. {
  559. File.Delete(folderPath);
  560. }
  561. DirectoryInfo tempfolder = new DirectoryInfo(folderPath);
  562. if (!tempfolder.Exists)
  563. {
  564. tempfolder.Create();
  565. }
  566. Settings.Default.BatesTemplateList[TemplateBatesItem.listIndex] = batesItem;
  567. Settings.Default.Save();
  568. }
  569. catch
  570. {
  571. }
  572. this.eventAggregator.GetEvent<EnterTemplateListOrCreateEvent>().Publish(new EnumTemplateListOrCreateUnicode
  573. {
  574. Unicode = Unicode,
  575. Status = EnumTemplateListOrCreate.StatusTemplate
  576. });
  577. }
  578. public void InitComponentBySelectedInfo()
  579. {
  580. ConvertItemToInfo(TemplateBatesItem, ref BatesInfo);
  581. for (int i = 0; i <= 5; i++)
  582. {
  583. GetTextValueFromNumber[i.ToString()] = BatesInfo.TextData[i].text;
  584. }
  585. MarginTopValue = BatesInfo.margin[0].ToString();
  586. MarginRightValue = BatesInfo.margin[1].ToString();
  587. MarginDownValue = BatesInfo.margin[2].ToString();
  588. MarginLeftValue = BatesInfo.margin[3].ToString();
  589. PrefixTextValue = BatesInfo.Prefix;
  590. SurfixTextValue = BatesInfo.Suffix;
  591. DigitNumberValue = BatesInfo.DigitNumber.ToString();
  592. FontNameSelectedIndex = FontNameList.IndexOf(BatesInfo.TextData[0].fontName);
  593. FontSizeSelectedIndex = FontSizeList.IndexOf(BatesInfo.TextData[0].fontSize.ToString());
  594. StarPagetNumberIndex = StarPagetNumberList.IndexOf(BatesInfo.StarPagetNumber.ToString());
  595. StringColor = EditToolsHelper.ConvertColor(BatesInfo.TextData[0].Color);
  596. SolidColorBrush = new SolidColorBrush(StringColor);
  597. PageRangeSelectIndex = BatesInfo.PageRangeIndex;
  598. }
  599. public bool IsNavigationTarget(NavigationContext navigationContext)
  600. {
  601. return true;
  602. }
  603. public void OnNavigatedFrom(NavigationContext navigationContext)
  604. {
  605. }
  606. public void OnNavigatedTo(NavigationContext navigationContext)
  607. {
  608. navigationContext.Parameters.TryGetValue<CPDFViewer>(ParameterNames.PDFViewer, out PDFViewer);
  609. //EditToolsHelper.GetPageRange(PageRangeSelectIndex, PDFViewer.Document, ref BatesInfo.PageRange, PageRangeText);
  610. if (navigationContext.Parameters.TryGetValue<BatesHeaderFooterItem>("BatesItem", out TemplateBatesItem))
  611. {
  612. CreateOrEdit = EnumCreateOrEdit.StatusEdit;
  613. InitComponentBySelectedInfo();
  614. }
  615. else
  616. {
  617. CreateOrEdit = EnumCreateOrEdit.StatusCreate;
  618. }
  619. }
  620. }
  621. }