HomePageBatesCreateContentViewModel.cs 25 KB

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