SettingsDialogViewModel.cs 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030
  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 _Settings_ResetAll = "";
  471. public string Settings_ResetAll
  472. {
  473. get { return _Settings_ResetAll; }
  474. set
  475. {
  476. SetProperty(ref _Settings_ResetAll, value);
  477. }
  478. }
  479. private string _Settings_Reset = "";
  480. public string Settings_Reset
  481. {
  482. get { return _Settings_Reset; }
  483. set
  484. {
  485. SetProperty(ref _Settings_Reset, value);
  486. }
  487. }
  488. private string _Settings_Display_DefaultV = "";
  489. public string Settings_Display_DefaultV
  490. {
  491. get { return _Settings_Display_DefaultV; }
  492. set
  493. {
  494. SetProperty(ref _Settings_Display_DefaultV, value);
  495. }
  496. }
  497. private void InitString()
  498. {
  499. Settings_Display_DefaultV = App.MainPageLoader.GetString("Settings_Display_DefaultV");
  500. Settings_Annotation_CircleFill = App.MainPageLoader.GetString("Settings_Annotation_CircleFill");
  501. Settings_Annotation_Freehand = App.MainPageLoader.GetString("Settings_Annotation_Freehand");
  502. Settings_Annotation_TextBox = App.MainPageLoader.GetString("Settings_Annotation_TextBox");
  503. Settings_Annotation_Line = App.MainPageLoader.GetString("Settings_Annotation_Line");
  504. Settings_Annotation_StickyNote = App.MainPageLoader.GetString("Settings_Annotation_StickyNote");
  505. Settings_Annotation_RectangleFill = App.MainPageLoader.GetString("Settings_Annotation_RectangleFill");
  506. Settings_Annotation_RectangleBorder = App.MainPageLoader.GetString("Settings_Annotation_RectangleBorder");
  507. Settings_Annotation_CircleBorder = App.MainPageLoader.GetString("Settings_Annotation_CircleBorder");
  508. Settings_Annotation_Text = App.MainPageLoader.GetString("Settings_Annotation_Text");
  509. Settings_Reset = App.MainPageLoader.GetString("Settings_Reset");
  510. Settings_ResetAll = App.MainPageLoader.GetString("Settings_ResetAll");
  511. Settings_Annotation_Strikethrough = App.MainPageLoader.GetString("Settings_Annotation_Strikethrough");
  512. Settings_Annotation_Underline = App.MainPageLoader.GetString("Settings_Annotation_Underline");
  513. Settings_Annotation_Highlight = App.MainPageLoader.GetString("Settings_Annotation_Highlight");
  514. Settings_Annotation_Annotation = App.MainPageLoader.GetString("Settings_Annotation_Annotation");
  515. Settings_Display_Highlight = App.MainPageLoader.GetString("Settings_Display_Highlight");
  516. Settings_Display_Collapse = App.MainPageLoader.GetString("Settings_Display_Collapse");
  517. Settings_Display_Fitwidth = App.MainPageLoader.GetString("Settings_Display_Fitwidth");
  518. Settings_General_Open = App.MainPageLoader.GetString("Settings_General_Open");
  519. Settings_General_Documents = App.MainPageLoader.GetString("Settings_General_Documents");
  520. Settings_Annotation = App.MainPageLoader.GetString("Settings_Annotation");
  521. Settings_Preferences = App.MainPageLoader.GetString("Settings_Preferences");
  522. Settings_General = App.MainPageLoader.GetString("Settings_General");
  523. Settings_Display = App.MainPageLoader.GetString("Settings_Display");
  524. Settings_General_Restore = App.MainPageLoader.GetString("Settings_General_Restore");
  525. Settings_General_Maximum = App.MainPageLoader.GetString("Settings_General_Maximum");
  526. Settings_General_Auto = App.MainPageLoader.GetString("Settings_General_Auto");
  527. Settings_General_Close = App.MainPageLoader.GetString("Settings_General_Close");
  528. Settings_General_ASave = App.MainPageLoader.GetString("Settings_General_ASave");
  529. Settings_General_Savedirectly = App.MainPageLoader.GetString("Settings_General_Savedirectly");
  530. Settings_General_Author = App.MainPageLoader.GetString("Settings_General_Author");
  531. Settings_Display_Default = App.MainPageLoader.GetString("Settings_Display_Default");
  532. Settings_Display_Page = App.MainPageLoader.GetString("Settings_Display_Page");
  533. Settings_Display_Singlepage = App.MainPageLoader.GetString("Settings_Display_Singlepage");
  534. Settings_Display_Singlepagecon = App.MainPageLoader.GetString("Settings_Display_Singlepagecon");
  535. Settings_Display_Twopage = App.MainPageLoader.GetString("Settings_Display_Twopage");
  536. Settings_Display_Fitpage = App.MainPageLoader.GetString("Settings_Display_Fitpage");
  537. Settings_Display_Twopagecon = App.MainPageLoader.GetString("Settings_Display_Twopagecon");
  538. Settings_Display_Bookmode = App.MainPageLoader.GetString("Settings_Display_Bookmode");
  539. Settings_Display_Bookmodecon = App.MainPageLoader.GetString("Settings_Display_Bookmodecon");
  540. Settings_Display_Zoom = App.MainPageLoader.GetString("Settings_Display_Zoom");
  541. Settings_Display_Actualsize = App.MainPageLoader.GetString("Settings_Display_Actualsize");
  542. Settings_Display_LeftPanel = App.MainPageLoader.GetString("Settings_Display_LeftPanel");
  543. Settings_Display_Properties = App.MainPageLoader.GetString("Settings_Display_Properties");
  544. Settings_Display_Show = App.MainPageLoader.GetString("Settings_Display_Show");
  545. Settings_Display_Display = App.MainPageLoader.GetString("Settings_Display_Display");
  546. Settings_Display_Remember = App.MainPageLoader.GetString("Settings_Display_Remember");
  547. Settings_Display_Auto = App.MainPageLoader.GetString("Settings_Display_Auto");
  548. Settings_Display_Normal = App.MainPageLoader.GetString("Settings_Display_Normal");
  549. Settings_Display_Background = App.MainPageLoader.GetString("Settings_Display_Background");
  550. Settings_Display_Manually = App.MainPageLoader.GetString("Settings_Display_Manually");
  551. Settings_Display_Full = App.MainPageLoader.GetString("Settings_Display_Full");
  552. }
  553. #endregion
  554. public AnnotateModel Annote { get; set; }
  555. public DescriptionModel Descript { get; set; }
  556. public InitialVIewModel View { get; set; }
  557. public DelegateCommand ResetCommand { get; set; }
  558. public DelegateCommand ResetAllCommand { get; set; }
  559. public ObservableCollection<string> AnnoteFamilyList { get; set; }
  560. public ObservableCollection<string> PageViewList { get; set; }
  561. public ObservableCollection<string> ZoomModeList { get; set; }
  562. private int noteSelectedIndex;
  563. public int NoteSelectedIndex
  564. {
  565. get { return noteSelectedIndex; }
  566. set
  567. {
  568. SetProperty(ref noteSelectedIndex, value);
  569. switch (value)
  570. {
  571. case 0:
  572. Annote.AnchoredFamaily = "Courier";
  573. break;
  574. case 1:
  575. Annote.AnchoredFamaily = "Helvetica";
  576. break;
  577. case 2:
  578. Annote.AnchoredFamaily = "Times New Roman";
  579. break;
  580. default:
  581. break;
  582. }
  583. }
  584. }
  585. private int annoteSelectedIndex;
  586. public int AnnoteSelectedIndex
  587. {
  588. get { return annoteSelectedIndex; }
  589. set
  590. {
  591. SetProperty(ref annoteSelectedIndex, value);
  592. switch (value)
  593. {
  594. case 0:
  595. Annote.TextFontFamaily = "Courier";
  596. break;
  597. case 1:
  598. Annote.TextFontFamaily = "Helvetica";
  599. break;
  600. case 2:
  601. Annote.TextFontFamaily = "Times New Roman";
  602. break;
  603. default:
  604. break;
  605. }
  606. }
  607. }
  608. private bool lefeSelected;
  609. public bool LeftSelected
  610. {
  611. get { return lefeSelected; }
  612. set
  613. {
  614. SetProperty(ref lefeSelected, value);
  615. if(value)
  616. {
  617. Annote.TextAlign = System.Windows.TextAlignment.Left;
  618. }
  619. }
  620. }
  621. private bool centerSelected;
  622. public bool CenterSelected
  623. {
  624. get { return centerSelected; }
  625. set
  626. {
  627. SetProperty(ref centerSelected, value);
  628. if (value)
  629. {
  630. Annote.TextAlign = System.Windows.TextAlignment.Center;
  631. }
  632. }
  633. }
  634. private bool rightSelected;
  635. public bool RightSelected
  636. {
  637. get { return rightSelected; }
  638. set
  639. {
  640. SetProperty(ref rightSelected, value);
  641. if (value)
  642. {
  643. Annote.TextAlign = System.Windows.TextAlignment.Right;
  644. }
  645. }
  646. }
  647. private bool strechSelected;
  648. public bool StrechSelected
  649. {
  650. get { return strechSelected; }
  651. set
  652. {
  653. SetProperty(ref strechSelected, value);
  654. if (value)
  655. {
  656. Annote.TextAlign = System.Windows.TextAlignment.Justify;
  657. }
  658. }
  659. }
  660. private int modeSelectedIndex;
  661. //选中的模式
  662. public int ModeSelectedIndex
  663. {
  664. get { return modeSelectedIndex; }
  665. set
  666. {
  667. SetProperty(ref modeSelectedIndex, value);
  668. }
  669. }
  670. private bool isDefualtApp;
  671. /// <summary>
  672. /// 是否是默认软件
  673. /// </summary>
  674. public bool IsDefualtApp
  675. {
  676. get { return isDefualtApp; }
  677. set { isDefualtApp = value; }
  678. }
  679. private bool isSetDefualtAppEnable;
  680. /// <summary>
  681. /// 是否允许设置默认软件
  682. /// </summary>
  683. public bool IsSetDefualtAppEnable
  684. {
  685. get { return isSetDefualtAppEnable; }
  686. set
  687. {
  688. SetProperty(ref isSetDefualtAppEnable, value);
  689. }
  690. }
  691. private int pageViewSelectedIndex;
  692. public int PageViewSelctedIndex
  693. {
  694. get { return pageViewSelectedIndex; }
  695. set
  696. {
  697. SetProperty(ref pageViewSelectedIndex, value);
  698. View.PageView = (ComPDFKitViewer.ViewMode)(value+1);
  699. }
  700. }
  701. private int zoomModeSelectedIndex ;
  702. public int ZoomModeSelectedIndex
  703. {
  704. get { return zoomModeSelectedIndex; }
  705. set
  706. {
  707. SetProperty(ref zoomModeSelectedIndex, value);
  708. switch (value)
  709. {
  710. case 0:
  711. View.ZoomMode = ComPDFKitViewer.FitMode.FitWidth;
  712. break;
  713. case 1:
  714. View.ZoomMode = ComPDFKitViewer.FitMode.FitHeight;
  715. break;
  716. case 2:
  717. View.ZoomMode = ComPDFKitViewer.FitMode.FitSize;
  718. break;
  719. default:
  720. break;
  721. }
  722. }
  723. }
  724. public SettingsDialogViewModel()
  725. {
  726. InitString();
  727. Annote = new AnnotateModel();
  728. Descript = new DescriptionModel();
  729. View = new InitialVIewModel();
  730. PageViewList = new ObservableCollection<string>();
  731. AnnoteFamilyList = new ObservableCollection<string>();
  732. ZoomModeList = new ObservableCollection<string>();
  733. ResetAllCommand = new DelegateCommand(resetAll);
  734. ResetCommand = new DelegateCommand(reset);
  735. InitAnnoteFamily();
  736. InitPageViews();
  737. InitZoomMode();
  738. //根据缓存还原下拉框 单选等
  739. InitAnnote();
  740. InitView();
  741. //判断是否以管理员身份运行
  742. IsSetDefualtAppEnable = Win32Helper.IsRunAsAdmin();
  743. IsDefualtApp = Win32Helper.IsDefaultApp();
  744. }
  745. private void InitView()
  746. {
  747. //页面模式下拉框
  748. PageViewSelctedIndex = (int)View.PageView - 1;
  749. //缩放模式下拉框
  750. switch (View.ZoomMode)
  751. {
  752. case ComPDFKitViewer.FitMode.FitWidth:
  753. ZoomModeSelectedIndex = 0;
  754. break;
  755. case ComPDFKitViewer.FitMode.FitHeight:
  756. ZoomModeSelectedIndex = 1;
  757. break;
  758. case ComPDFKitViewer.FitMode.FitSize:
  759. zoomModeSelectedIndex = 2;
  760. break;
  761. case ComPDFKitViewer.FitMode.FitFree:
  762. //TODO:
  763. break;
  764. default:
  765. break;
  766. }
  767. }
  768. private void InitAnnote()
  769. {
  770. //注释对齐方式
  771. switch (Annote.TextAlign)
  772. {
  773. case System.Windows.TextAlignment.Left:
  774. LeftSelected = true;
  775. break;
  776. case System.Windows.TextAlignment.Right:
  777. RightSelected = true;
  778. break;
  779. case System.Windows.TextAlignment.Center:
  780. CenterSelected = true;
  781. break;
  782. case System.Windows.TextAlignment.Justify:
  783. default:
  784. StrechSelected = true;
  785. break;
  786. }
  787. //文本注释字体
  788. if(Annote.TextFontFamaily== "Courier")
  789. {
  790. AnnoteSelectedIndex = 0;
  791. }
  792. else if(Annote.TextFontFamaily== "Helvetica")
  793. {
  794. AnnoteSelectedIndex = 1;
  795. }
  796. else
  797. {
  798. AnnoteSelectedIndex = 2;
  799. }
  800. //便签注释字体
  801. if (Annote.AnchoredFamaily == "Courier")
  802. {
  803. NoteSelectedIndex = 0;
  804. }
  805. else if (Annote.AnchoredFamaily == "Helvetica")
  806. {
  807. NoteSelectedIndex = 1;
  808. }
  809. else
  810. {
  811. NoteSelectedIndex = 2;
  812. }
  813. }
  814. private void InitPageViews()
  815. {
  816. PageViewList.Clear();
  817. PageViewList.Add(Settings_Display_Singlepage);
  818. PageViewList.Add(Settings_Display_Singlepagecon);
  819. PageViewList.Add(Settings_Display_Twopage);
  820. PageViewList.Add(Settings_Display_Twopagecon);
  821. PageViewList.Add(Settings_Display_Bookmode);
  822. PageViewList.Add(Settings_Display_Bookmodecon);
  823. }
  824. private void InitZoomMode()
  825. {
  826. ZoomModeList.Clear();
  827. ZoomModeList.Add(Settings_Display_Fitwidth);
  828. ZoomModeList.Add(Settings_Display_Fitpage);
  829. ZoomModeList.Add(Settings_Display_Actualsize);
  830. }
  831. private void InitAnnoteFamily()
  832. {
  833. AnnoteFamilyList.Clear();
  834. AnnoteFamilyList.Add("Courier New");
  835. AnnoteFamilyList.Add("Arial");
  836. AnnoteFamilyList.Add("Times New Roman");
  837. }
  838. /// <summary>
  839. /// 重置
  840. /// </summary>
  841. private void reset()
  842. {
  843. switch (ModeSelectedIndex)
  844. {
  845. case 0:
  846. Descript.Reset();
  847. break;
  848. case 1:
  849. View.Reset();
  850. InitView();
  851. break;
  852. case 2:
  853. Annote.Reset();
  854. InitAnnote();
  855. break;
  856. default:
  857. break;
  858. }
  859. }
  860. /// <summary>
  861. /// 全部重置
  862. /// </summary>
  863. private void resetAll()
  864. {
  865. View.Reset();
  866. Descript.Reset();
  867. Annote.Reset();
  868. InitAnnote();
  869. InitView();
  870. }
  871. public bool CanCloseDialog()
  872. {
  873. return true;
  874. }
  875. public void OnDialogClosed()
  876. {
  877. try
  878. {
  879. View.Save();
  880. Annote.Save();
  881. Descript.Save();
  882. Win32Helper.RegisterDefaultApp(IsDefualtApp);
  883. Settings.Default.Save();
  884. }
  885. catch { }
  886. }
  887. public void OnDialogOpened(IDialogParameters parameters)
  888. {
  889. }
  890. }
  891. }