SettingsDialogViewModel.cs 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  1. using PDF_Master.Helper;
  2. using PDF_Master.Model.SettingsDialog;
  3. using PDF_Master.Properties;
  4. using Prism.Commands;
  5. using Prism.Mvvm;
  6. using Prism.Services.Dialogs;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Collections.ObjectModel;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. namespace PDF_Master.ViewModels.Dialog
  14. {
  15. public class SettingsDialogViewModel : BindableBase, IDialogAware
  16. {
  17. public string Title => "";
  18. public event Action<IDialogResult> RequestClose;
  19. #region 文案
  20. private string _Settings_Preferences = "";
  21. public string Settings_Preferences
  22. {
  23. get { return _Settings_Preferences; }
  24. set
  25. {
  26. SetProperty(ref _Settings_Preferences, value);
  27. }
  28. }
  29. private string _Settings_General = "";
  30. public string Settings_General
  31. {
  32. get { return _Settings_General; }
  33. set
  34. {
  35. SetProperty(ref _Settings_General, value);
  36. }
  37. }
  38. private string _Settings_Display = "";
  39. public string Settings_Display
  40. {
  41. get { return _Settings_Display; }
  42. set
  43. {
  44. SetProperty(ref _Settings_Display, value);
  45. }
  46. }
  47. private string _Settings_Annotation = "";
  48. public string Settings_Annotation
  49. {
  50. get { return _Settings_Annotation; }
  51. set
  52. {
  53. SetProperty(ref _Settings_Annotation, value);
  54. }
  55. }
  56. private string _Settings_General_Documents = "";
  57. public string Settings_General_Documents
  58. {
  59. get { return _Settings_General_Documents; }
  60. set
  61. {
  62. SetProperty(ref _Settings_General_Documents, value);
  63. }
  64. }
  65. private string _Settings_General_Open = "";
  66. public string Settings_General_Open
  67. {
  68. get { return _Settings_General_Open; }
  69. set
  70. {
  71. SetProperty(ref _Settings_General_Open, value);
  72. }
  73. }
  74. private string _Settings_General_Restore = "";
  75. public string Settings_General_Restore
  76. {
  77. get { return _Settings_General_Restore; }
  78. set
  79. {
  80. SetProperty(ref _Settings_General_Restore, value);
  81. }
  82. }
  83. private string _Settings_General_Maximum = "";
  84. public string Settings_General_Maximum
  85. {
  86. get { return _Settings_General_Maximum; }
  87. set
  88. {
  89. SetProperty(ref _Settings_General_Maximum, value);
  90. }
  91. }
  92. private string _Settings_General_Auto = "";
  93. public string Settings_General_Auto
  94. {
  95. get { return _Settings_General_Auto; }
  96. set
  97. {
  98. SetProperty(ref _Settings_General_Auto, value);
  99. }
  100. }
  101. private string _Settings_General_Close = "";
  102. public string Settings_General_Close
  103. {
  104. get { return _Settings_General_Close; }
  105. set
  106. {
  107. SetProperty(ref _Settings_General_Close, value);
  108. }
  109. }
  110. private string _Settings_General_ASave = "";
  111. public string Settings_General_ASave
  112. {
  113. get { return _Settings_General_ASave; }
  114. set
  115. {
  116. SetProperty(ref _Settings_General_ASave, value);
  117. }
  118. }
  119. private string _Settings_General_Savedirectly = "";
  120. public string Settings_General_Savedirectly
  121. {
  122. get { return _Settings_General_Savedirectly; }
  123. set
  124. {
  125. SetProperty(ref _Settings_General_Savedirectly, value);
  126. }
  127. }
  128. private string _Settings_General_Author = "";
  129. public string Settings_General_Author
  130. {
  131. get { return _Settings_General_Author; }
  132. set
  133. {
  134. SetProperty(ref _Settings_General_Author, value);
  135. }
  136. }
  137. private string _Settings_Display_Default = "";
  138. public string Settings_Display_Default
  139. {
  140. get { return _Settings_Display_Default; }
  141. set
  142. {
  143. SetProperty(ref _Settings_Display_Default, value);
  144. }
  145. }
  146. private string _Settings_Display_Page = "";
  147. public string Settings_Display_Page
  148. {
  149. get { return _Settings_Display_Page; }
  150. set
  151. {
  152. SetProperty(ref _Settings_Display_Page, value);
  153. }
  154. }
  155. private string _Settings_Display_Singlepage = "";
  156. public string Settings_Display_Singlepage
  157. {
  158. get { return _Settings_Display_Singlepage; }
  159. set
  160. {
  161. SetProperty(ref _Settings_Display_Singlepage, value);
  162. }
  163. }
  164. private string _Settings_Display_Singlepagecon = "";
  165. public string Settings_Display_Singlepagecon
  166. {
  167. get { return _Settings_Display_Singlepagecon; }
  168. set
  169. {
  170. SetProperty(ref _Settings_Display_Singlepagecon, value);
  171. }
  172. }
  173. private string _Settings_Display_Twopage = "";
  174. public string Settings_Display_Twopage
  175. {
  176. get { return _Settings_Display_Twopage; }
  177. set
  178. {
  179. SetProperty(ref _Settings_Display_Twopage, value);
  180. }
  181. }
  182. private string _Settings_Display_Twopagecon = "";
  183. public string Settings_Display_Twopagecon
  184. {
  185. get { return _Settings_Display_Twopagecon; }
  186. set
  187. {
  188. SetProperty(ref _Settings_Display_Twopagecon, value);
  189. }
  190. }
  191. private string _Settings_Display_Bookmode = "";
  192. public string Settings_Display_Bookmode
  193. {
  194. get { return _Settings_Display_Bookmode; }
  195. set
  196. {
  197. SetProperty(ref _Settings_Display_Bookmode, value);
  198. }
  199. }
  200. private string _Settings_Display_Bookmodecon = "";
  201. public string Settings_Display_Bookmodecon
  202. {
  203. get { return _Settings_Display_Bookmodecon; }
  204. set
  205. {
  206. SetProperty(ref _Settings_Display_Bookmodecon, value);
  207. }
  208. }
  209. private string _Settings_Display_Zoom = "";
  210. public string Settings_Display_Zoom
  211. {
  212. get { return _Settings_Display_Zoom; }
  213. set
  214. {
  215. SetProperty(ref _Settings_Display_Zoom, value);
  216. }
  217. }
  218. private string _Settings_Display_Fitwidth = "";
  219. public string Settings_Display_Fitwidth
  220. {
  221. get { return _Settings_Display_Fitwidth; }
  222. set
  223. {
  224. SetProperty(ref _Settings_Display_Fitwidth, value);
  225. }
  226. }
  227. private string _Settings_Display_Fitpage = "";
  228. public string Settings_Display_Fitpage
  229. {
  230. get { return _Settings_Display_Fitpage; }
  231. set
  232. {
  233. SetProperty(ref _Settings_Display_Fitpage, value);
  234. }
  235. }
  236. private string _Settings_Display_Actualsize = "";
  237. public string Settings_Display_Actualsize
  238. {
  239. get { return _Settings_Display_Actualsize; }
  240. set
  241. {
  242. SetProperty(ref _Settings_Display_Actualsize, value);
  243. }
  244. }
  245. private string _Settings_Display_LeftPanel = "";
  246. public string Settings_Display_LeftPanel
  247. {
  248. get { return _Settings_Display_LeftPanel; }
  249. set
  250. {
  251. SetProperty(ref _Settings_Display_LeftPanel, value);
  252. }
  253. }
  254. private string _Settings_Display_Collapse = "";
  255. public string Settings_Display_Collapse
  256. {
  257. get { return _Settings_Display_Collapse; }
  258. set
  259. {
  260. SetProperty(ref _Settings_Display_Collapse, value);
  261. }
  262. }
  263. private string _Settings_Display_Remember = "";
  264. public string Settings_Display_Remember
  265. {
  266. get { return _Settings_Display_Remember; }
  267. set
  268. {
  269. SetProperty(ref _Settings_Display_Remember, value);
  270. }
  271. }
  272. private string _Settings_Display_Show = "";
  273. public string Settings_Display_Show
  274. {
  275. get { return _Settings_Display_Show; }
  276. set
  277. {
  278. SetProperty(ref _Settings_Display_Show, value);
  279. }
  280. }
  281. private string _Settings_Display_Properties = "";
  282. public string Settings_Display_Properties
  283. {
  284. get { return _Settings_Display_Properties; }
  285. set
  286. {
  287. SetProperty(ref _Settings_Display_Properties, value);
  288. }
  289. }
  290. private string _Settings_Display_Display = "";
  291. public string Settings_Display_Display
  292. {
  293. get { return _Settings_Display_Display; }
  294. set
  295. {
  296. SetProperty(ref _Settings_Display_Display, value);
  297. }
  298. }
  299. private string _Settings_Display_Auto = "";
  300. public string Settings_Display_Auto
  301. {
  302. get { return _Settings_Display_Auto; }
  303. set
  304. {
  305. SetProperty(ref _Settings_Display_Auto, value);
  306. }
  307. }
  308. private string _Settings_Display_Manually = "";
  309. public string Settings_Display_Manually
  310. {
  311. get { return _Settings_Display_Manually; }
  312. set
  313. {
  314. SetProperty(ref _Settings_Display_Manually, value);
  315. }
  316. }
  317. private string _Settings_Display_Background = "";
  318. public string Settings_Display_Background
  319. {
  320. get { return _Settings_Display_Background; }
  321. set
  322. {
  323. SetProperty(ref _Settings_Display_Background, value);
  324. }
  325. }
  326. private string _Settings_Display_Normal = "";
  327. public string Settings_Display_Normal
  328. {
  329. get { return _Settings_Display_Normal; }
  330. set
  331. {
  332. SetProperty(ref _Settings_Display_Normal, value);
  333. }
  334. }
  335. private string _Settings_Display_Full = "";
  336. public string Settings_Display_Full
  337. {
  338. get { return _Settings_Display_Full; }
  339. set
  340. {
  341. SetProperty(ref _Settings_Display_Full, value);
  342. }
  343. }
  344. private string _Settings_Display_Highlight = "";
  345. public string Settings_Display_Highlight
  346. {
  347. get { return _Settings_Display_Highlight; }
  348. set
  349. {
  350. SetProperty(ref _Settings_Display_Highlight, value);
  351. }
  352. }
  353. private string _Settings_Annotation_Annotation = "";
  354. public string Settings_Annotation_Annotation
  355. {
  356. get { return _Settings_Annotation_Annotation; }
  357. set
  358. {
  359. SetProperty(ref _Settings_Annotation_Annotation, value);
  360. }
  361. }
  362. private string _Settings_Annotation_Highlight = "";
  363. public string Settings_Annotation_Highlight
  364. {
  365. get { return _Settings_Annotation_Highlight; }
  366. set
  367. {
  368. SetProperty(ref _Settings_Annotation_Highlight, value);
  369. }
  370. }
  371. private string _Settings_Annotation_Underline = "";
  372. public string Settings_Annotation_Underline
  373. {
  374. get { return _Settings_Annotation_Underline; }
  375. set
  376. {
  377. SetProperty(ref _Settings_Annotation_Underline, value);
  378. }
  379. }
  380. private string _Settings_Annotation_Strikethrough = "";
  381. public string Settings_Annotation_Strikethrough
  382. {
  383. get { return _Settings_Annotation_Strikethrough; }
  384. set
  385. {
  386. SetProperty(ref _Settings_Annotation_Strikethrough, value);
  387. }
  388. }
  389. private string _Settings_Annotation_Freehand = "";
  390. public string Settings_Annotation_Freehand
  391. {
  392. get { return _Settings_Annotation_Freehand; }
  393. set
  394. {
  395. SetProperty(ref _Settings_Annotation_Freehand, value);
  396. }
  397. }
  398. private string _Settings_Annotation_TextBox = "";
  399. public string Settings_Annotation_TextBox
  400. {
  401. get { return _Settings_Annotation_TextBox; }
  402. set
  403. {
  404. SetProperty(ref _Settings_Annotation_TextBox, value);
  405. }
  406. }
  407. private string _Settings_Annotation_StickyNote = "";
  408. public string Settings_Annotation_StickyNote
  409. {
  410. get { return _Settings_Annotation_StickyNote; }
  411. set
  412. {
  413. SetProperty(ref _Settings_Annotation_StickyNote, value);
  414. }
  415. }
  416. private string _Settings_Annotation_RectangleBorder = "";
  417. public string Settings_Annotation_RectangleBorder
  418. {
  419. get { return _Settings_Annotation_RectangleBorder; }
  420. set
  421. {
  422. SetProperty(ref _Settings_Annotation_RectangleBorder, value);
  423. }
  424. }
  425. private string _Settings_Annotation_CircleBorder = "";
  426. public string Settings_Annotation_CircleBorder
  427. {
  428. get { return _Settings_Annotation_CircleBorder; }
  429. set
  430. {
  431. SetProperty(ref _Settings_Annotation_CircleBorder, value);
  432. }
  433. }
  434. private string _Settings_Annotation_Line = "";
  435. public string Settings_Annotation_Line
  436. {
  437. get { return _Settings_Annotation_Line; }
  438. set
  439. {
  440. SetProperty(ref _Settings_Annotation_Line, value);
  441. }
  442. }
  443. private string _Settings_Annotation_RectangleFill = "";
  444. public string Settings_Annotation_RectangleFill
  445. {
  446. get { return _Settings_Annotation_RectangleFill; }
  447. set
  448. {
  449. SetProperty(ref _Settings_Annotation_RectangleFill, value);
  450. }
  451. }
  452. private string _Settings_Annotation_CircleFill = "";
  453. public string Settings_Annotation_CircleFill
  454. {
  455. get { return _Settings_Annotation_CircleFill; }
  456. set
  457. {
  458. SetProperty(ref _Settings_Annotation_CircleFill, value);
  459. }
  460. }
  461. private string _Settings_Annotation_Text = "";
  462. public string Settings_Annotation_Text
  463. {
  464. get { return _Settings_Annotation_Text; }
  465. set
  466. {
  467. SetProperty(ref _Settings_Annotation_Text, value);
  468. }
  469. }
  470. private string T_settings_Annotation_Font = "";
  471. public string T_Settings_Annotation_Font
  472. {
  473. get { return T_settings_Annotation_Font; }
  474. set
  475. {
  476. SetProperty(ref T_settings_Annotation_Font, value);
  477. }
  478. }
  479. private string _Settings_ResetAll = "";
  480. public string Settings_ResetAll
  481. {
  482. get { return _Settings_ResetAll; }
  483. set
  484. {
  485. SetProperty(ref _Settings_ResetAll, value);
  486. }
  487. }
  488. private string _Settings_Reset = "";
  489. public string Settings_Reset
  490. {
  491. get { return _Settings_Reset; }
  492. set
  493. {
  494. SetProperty(ref _Settings_Reset, value);
  495. }
  496. }
  497. private string _Settings_Display_DefaultV = "";
  498. public string Settings_Display_DefaultV
  499. {
  500. get { return _Settings_Display_DefaultV; }
  501. set
  502. {
  503. SetProperty(ref _Settings_Display_DefaultV, value);
  504. }
  505. }
  506. private void InitString()
  507. {
  508. Settings_Display_DefaultV = App.MainPageLoader.GetString("Settings_Display_DefaultV");
  509. Settings_Annotation_CircleFill = App.MainPageLoader.GetString("Settings_Annotation_CircleFill");
  510. Settings_Annotation_Freehand = App.MainPageLoader.GetString("Settings_Annotation_Freehand");
  511. Settings_Annotation_TextBox = App.MainPageLoader.GetString("Settings_Annotation_TextBox");
  512. Settings_Annotation_Line = App.MainPageLoader.GetString("Settings_Annotation_Line");
  513. Settings_Annotation_StickyNote = App.MainPageLoader.GetString("Settings_Annotation_StickyNote");
  514. Settings_Annotation_RectangleFill = App.MainPageLoader.GetString("Settings_Annotation_RectangleFill");
  515. Settings_Annotation_RectangleBorder = App.MainPageLoader.GetString("Settings_Annotation_RectangleBorder");
  516. Settings_Annotation_CircleBorder = App.MainPageLoader.GetString("Settings_Annotation_CircleBorder");
  517. Settings_Annotation_Text = App.MainPageLoader.GetString("Settings_Annotation_Text");
  518. Settings_Reset = App.MainPageLoader.GetString("Settings_Reset");
  519. Settings_ResetAll = App.MainPageLoader.GetString("Settings_ResetAll");
  520. Settings_Annotation_Strikethrough = App.MainPageLoader.GetString("Settings_Annotation_Strikethrough");
  521. Settings_Annotation_Underline = App.MainPageLoader.GetString("Settings_Annotation_Underline");
  522. Settings_Annotation_Highlight = App.MainPageLoader.GetString("Settings_Annotation_Highlight");
  523. Settings_Annotation_Annotation = App.MainPageLoader.GetString("Settings_Annotation_Annotation");
  524. Settings_Display_Highlight = App.MainPageLoader.GetString("Settings_Display_Highlight");
  525. Settings_Display_Collapse = App.MainPageLoader.GetString("Settings_Display_Collapse");
  526. Settings_Display_Fitwidth = App.MainPageLoader.GetString("Settings_Display_Fitwidth");
  527. Settings_General_Open = App.MainPageLoader.GetString("Settings_General_Open");
  528. Settings_General_Documents = App.MainPageLoader.GetString("Settings_General_Documents");
  529. Settings_Annotation = App.MainPageLoader.GetString("Settings_Annotation");
  530. Settings_Preferences = App.MainPageLoader.GetString("Settings_Preferences");
  531. Settings_General = App.MainPageLoader.GetString("Settings_General");
  532. Settings_Display = App.MainPageLoader.GetString("Settings_Display");
  533. Settings_General_Restore = App.MainPageLoader.GetString("Settings_General_Restore");
  534. Settings_General_Maximum = App.MainPageLoader.GetString("Settings_General_Maximum");
  535. Settings_General_Auto = App.MainPageLoader.GetString("Settings_General_Auto");
  536. Settings_General_Close = App.MainPageLoader.GetString("Settings_General_Close");
  537. Settings_General_ASave = App.MainPageLoader.GetString("Settings_General_ASave");
  538. Settings_General_Savedirectly = App.MainPageLoader.GetString("Settings_General_Savedirectly");
  539. Settings_General_Author = App.MainPageLoader.GetString("Settings_General_Author");
  540. Settings_Display_Default = App.MainPageLoader.GetString("Settings_Display_Default");
  541. Settings_Display_Page = App.MainPageLoader.GetString("Settings_Display_Page");
  542. Settings_Display_Singlepage = App.MainPageLoader.GetString("Settings_Display_Singlepage");
  543. Settings_Display_Singlepagecon = App.MainPageLoader.GetString("Settings_Display_Singlepagecon");
  544. Settings_Display_Twopage = App.MainPageLoader.GetString("Settings_Display_Twopage");
  545. Settings_Display_Fitpage = App.MainPageLoader.GetString("Settings_Display_Fitpage");
  546. Settings_Display_Twopagecon = App.MainPageLoader.GetString("Settings_Display_Twopagecon");
  547. Settings_Display_Bookmode = App.MainPageLoader.GetString("Settings_Display_Bookmode");
  548. Settings_Display_Bookmodecon = App.MainPageLoader.GetString("Settings_Display_Bookmodecon");
  549. Settings_Display_Zoom = App.MainPageLoader.GetString("Settings_Display_Zoom");
  550. Settings_Display_Actualsize = App.MainPageLoader.GetString("Settings_Display_Actualsize");
  551. Settings_Display_LeftPanel = App.MainPageLoader.GetString("Settings_Display_LeftPanel");
  552. Settings_Display_Properties = App.MainPageLoader.GetString("Settings_Display_Properties");
  553. Settings_Display_Show = App.MainPageLoader.GetString("Settings_Display_Show");
  554. Settings_Display_Display = App.MainPageLoader.GetString("Settings_Display_Display");
  555. Settings_Display_Remember = App.MainPageLoader.GetString("Settings_Display_Remember");
  556. Settings_Display_Auto = App.MainPageLoader.GetString("Settings_Display_Auto");
  557. Settings_Display_Normal = App.MainPageLoader.GetString("Settings_Display_Normal");
  558. Settings_Display_Background = App.MainPageLoader.GetString("Settings_Display_Background");
  559. Settings_Display_Manually = App.MainPageLoader.GetString("Settings_Display_Manually");
  560. Settings_Display_Full = App.MainPageLoader.GetString("Settings_Display_Full");
  561. T_Settings_Annotation_Font = App.MainPageLoader.GetString("Settings_Annotation_Annotation_Font");
  562. }
  563. #endregion
  564. public AnnotateModel Annote { get; set; }
  565. public DescriptionModel Descript { get; set; }
  566. public InitialVIewModel View { get; set; }
  567. public DelegateCommand ResetCommand { get; set; }
  568. public DelegateCommand ResetAllCommand { get; set; }
  569. public ObservableCollection<string> AnnoteFamilyList { get; set; }
  570. public ObservableCollection<string> PageViewList { get; set; }
  571. public ObservableCollection<string> ZoomModeList { get; set; }
  572. private int noteSelectedIndex;
  573. public int NoteSelectedIndex
  574. {
  575. get { return noteSelectedIndex; }
  576. set
  577. {
  578. SetProperty(ref noteSelectedIndex, value);
  579. switch (value)
  580. {
  581. case 0:
  582. Annote.AnchoredFamaily = "Courier";
  583. break;
  584. case 1:
  585. Annote.AnchoredFamaily = "Helvetica";
  586. break;
  587. case 2:
  588. Annote.AnchoredFamaily = "Times New Roman";
  589. break;
  590. default:
  591. break;
  592. }
  593. }
  594. }
  595. private int annoteSelectedIndex;
  596. public int AnnoteSelectedIndex
  597. {
  598. get { return annoteSelectedIndex; }
  599. set
  600. {
  601. SetProperty(ref annoteSelectedIndex, value);
  602. switch (value)
  603. {
  604. case 0:
  605. Annote.TextFontFamaily = "Courier New";
  606. break;
  607. case 1:
  608. Annote.TextFontFamaily = "Helvetica";
  609. break;
  610. case 2:
  611. Annote.TextFontFamaily = "Times New Roman";
  612. break;
  613. default:
  614. break;
  615. }
  616. }
  617. }
  618. private bool lefeSelected;
  619. public bool LeftSelected
  620. {
  621. get { return lefeSelected; }
  622. set
  623. {
  624. SetProperty(ref lefeSelected, value);
  625. if(value)
  626. {
  627. Annote.TextAlign = System.Windows.TextAlignment.Left;
  628. }
  629. }
  630. }
  631. private bool centerSelected;
  632. public bool CenterSelected
  633. {
  634. get { return centerSelected; }
  635. set
  636. {
  637. SetProperty(ref centerSelected, value);
  638. if (value)
  639. {
  640. Annote.TextAlign = System.Windows.TextAlignment.Center;
  641. }
  642. }
  643. }
  644. private bool rightSelected;
  645. public bool RightSelected
  646. {
  647. get { return rightSelected; }
  648. set
  649. {
  650. SetProperty(ref rightSelected, value);
  651. if (value)
  652. {
  653. Annote.TextAlign = System.Windows.TextAlignment.Right;
  654. }
  655. }
  656. }
  657. private bool strechSelected;
  658. public bool StrechSelected
  659. {
  660. get { return strechSelected; }
  661. set
  662. {
  663. SetProperty(ref strechSelected, value);
  664. if (value)
  665. {
  666. Annote.TextAlign = System.Windows.TextAlignment.Justify;
  667. }
  668. }
  669. }
  670. private int modeSelectedIndex;
  671. //选中的模式
  672. public int ModeSelectedIndex
  673. {
  674. get { return modeSelectedIndex; }
  675. set
  676. {
  677. SetProperty(ref modeSelectedIndex, value);
  678. }
  679. }
  680. private bool isDefualtApp;
  681. /// <summary>
  682. /// 是否是默认软件
  683. /// </summary>
  684. public bool IsDefualtApp
  685. {
  686. get { return isDefualtApp; }
  687. set { isDefualtApp = value; }
  688. }
  689. private bool isSetDefualtAppEnable;
  690. /// <summary>
  691. /// 是否允许设置默认软件
  692. /// </summary>
  693. public bool IsSetDefualtAppEnable
  694. {
  695. get { return isSetDefualtAppEnable; }
  696. set
  697. {
  698. SetProperty(ref isSetDefualtAppEnable, value);
  699. }
  700. }
  701. private int pageViewSelectedIndex;
  702. public int PageViewSelctedIndex
  703. {
  704. get { return pageViewSelectedIndex; }
  705. set
  706. {
  707. SetProperty(ref pageViewSelectedIndex, value);
  708. View.PageView = (ComPDFKitViewer.ViewMode)(value+1);
  709. }
  710. }
  711. private int zoomModeSelectedIndex ;
  712. public int ZoomModeSelectedIndex
  713. {
  714. get { return zoomModeSelectedIndex; }
  715. set
  716. {
  717. SetProperty(ref zoomModeSelectedIndex, value);
  718. switch (value)
  719. {
  720. case 0:
  721. View.ZoomMode = ComPDFKitViewer.FitMode.FitWidth;
  722. break;
  723. case 1:
  724. View.ZoomMode = ComPDFKitViewer.FitMode.FitHeight;
  725. break;
  726. case 2:
  727. View.ZoomMode = ComPDFKitViewer.FitMode.FitSize;
  728. break;
  729. default:
  730. break;
  731. }
  732. }
  733. }
  734. private bool autoSaveEnable = true;
  735. /// <summary>
  736. /// 是否允许设置自动保存
  737. /// 未付费用户 不进行自动保存
  738. /// </summary>
  739. public bool AutoSaveEnable
  740. {
  741. get { return autoSaveEnable; }
  742. set { autoSaveEnable = value; }
  743. }
  744. public SettingsDialogViewModel()
  745. {
  746. InitString();
  747. Annote = new AnnotateModel();
  748. Descript = new DescriptionModel();
  749. View = new InitialVIewModel();
  750. PageViewList = new ObservableCollection<string>();
  751. AnnoteFamilyList = new ObservableCollection<string>();
  752. ZoomModeList = new ObservableCollection<string>();
  753. ResetAllCommand = new DelegateCommand(resetAll);
  754. ResetCommand = new DelegateCommand(reset);
  755. InitAnnoteFamily();
  756. InitPageViews();
  757. InitZoomMode();
  758. //根据缓存还原下拉框 单选等
  759. InitAnnote();
  760. InitView();
  761. //判断是否以管理员身份运行
  762. IsSetDefualtAppEnable = Win32Helper.IsRunAsAdmin();
  763. IsDefualtApp = Win32Helper.IsDefaultApp();
  764. //未付费用户不进行自动保存
  765. if (!App.IsLogin || Settings.Default.UserDate.subscribestatus != 1)
  766. {
  767. AutoSaveEnable = false;
  768. Descript.AutoSave = false;
  769. }
  770. }
  771. private void InitView()
  772. {
  773. //页面模式下拉框
  774. PageViewSelctedIndex = (int)View.PageView - 1;
  775. //缩放模式下拉框
  776. switch (View.ZoomMode)
  777. {
  778. case ComPDFKitViewer.FitMode.FitWidth:
  779. ZoomModeSelectedIndex = 0;
  780. break;
  781. case ComPDFKitViewer.FitMode.FitHeight:
  782. ZoomModeSelectedIndex = 1;
  783. break;
  784. case ComPDFKitViewer.FitMode.FitSize:
  785. zoomModeSelectedIndex = 2;
  786. break;
  787. case ComPDFKitViewer.FitMode.FitFree:
  788. //TODO:
  789. break;
  790. default:
  791. break;
  792. }
  793. }
  794. private void InitAnnote()
  795. {
  796. //注释对齐方式
  797. switch (Annote.TextAlign)
  798. {
  799. case System.Windows.TextAlignment.Left:
  800. LeftSelected = true;
  801. break;
  802. case System.Windows.TextAlignment.Right:
  803. RightSelected = true;
  804. break;
  805. case System.Windows.TextAlignment.Center:
  806. CenterSelected = true;
  807. break;
  808. case System.Windows.TextAlignment.Justify:
  809. default:
  810. StrechSelected = true;
  811. break;
  812. }
  813. //文本注释字体
  814. if(Annote.TextFontFamaily== "Courier New")
  815. {
  816. AnnoteSelectedIndex = 0;
  817. }
  818. else if(Annote.TextFontFamaily== "Helvetica")
  819. {
  820. AnnoteSelectedIndex = 1;
  821. }
  822. else
  823. {
  824. AnnoteSelectedIndex = 2;
  825. }
  826. //便签注释字体
  827. if (Annote.AnchoredFamaily == "Courier")
  828. {
  829. NoteSelectedIndex = 0;
  830. }
  831. else if (Annote.AnchoredFamaily == "Helvetica")
  832. {
  833. NoteSelectedIndex = 1;
  834. }
  835. else
  836. {
  837. NoteSelectedIndex = 2;
  838. }
  839. }
  840. private void InitPageViews()
  841. {
  842. PageViewList.Clear();
  843. PageViewList.Add(Settings_Display_Singlepage);
  844. PageViewList.Add(Settings_Display_Singlepagecon);
  845. PageViewList.Add(Settings_Display_Twopage);
  846. PageViewList.Add(Settings_Display_Twopagecon);
  847. PageViewList.Add(Settings_Display_Bookmode);
  848. PageViewList.Add(Settings_Display_Bookmodecon);
  849. }
  850. private void InitZoomMode()
  851. {
  852. ZoomModeList.Clear();
  853. ZoomModeList.Add(Settings_Display_Fitwidth);
  854. ZoomModeList.Add(Settings_Display_Fitpage);
  855. ZoomModeList.Add(Settings_Display_Actualsize);
  856. }
  857. private void InitAnnoteFamily()
  858. {
  859. AnnoteFamilyList.Clear();
  860. AnnoteFamilyList.Add("Courier New");
  861. AnnoteFamilyList.Add("Arial");
  862. AnnoteFamilyList.Add("Times New Roman");
  863. }
  864. /// <summary>
  865. /// 重置
  866. /// </summary>
  867. private void reset()
  868. {
  869. switch (ModeSelectedIndex)
  870. {
  871. case 0:
  872. Descript.Reset();
  873. //未付费用户不进行自动保存
  874. if (!App.IsLogin || Settings.Default.UserDate.subscribestatus != 1)
  875. {
  876. AutoSaveEnable = false;
  877. Descript.AutoSave = false;
  878. }
  879. break;
  880. case 1:
  881. View.Reset();
  882. InitView();
  883. break;
  884. case 2:
  885. Annote.Reset();
  886. InitAnnote();
  887. break;
  888. default:
  889. break;
  890. }
  891. }
  892. /// <summary>
  893. /// 全部重置
  894. /// </summary>
  895. private void resetAll()
  896. {
  897. View.Reset();
  898. Descript.Reset();
  899. //未付费用户不进行自动保存
  900. if (!App.IsLogin || Settings.Default.UserDate.subscribestatus != 1)
  901. {
  902. AutoSaveEnable = false;
  903. Descript.AutoSave = false;
  904. }
  905. Annote.Reset();
  906. InitAnnote();
  907. InitView();
  908. }
  909. public bool CanCloseDialog()
  910. {
  911. return true;
  912. }
  913. public void OnDialogClosed()
  914. {
  915. try
  916. {
  917. View.Save();
  918. Annote.Save();
  919. Descript.Save();
  920. Win32Helper.RegisterDefaultApp(IsDefualtApp);
  921. Settings.Default.Save();
  922. //弹窗已关闭调用再次关闭方法会异常
  923. //RequestClose.Invoke(new DialogResult());
  924. }
  925. catch { }
  926. }
  927. public void OnDialogOpened(IDialogParameters parameters)
  928. {
  929. }
  930. }
  931. }