HomePageBatesCreateContentViewModel.cs 25 KB

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