SettingsDialogViewModel.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062
  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. break;
  874. case 1:
  875. View.Reset();
  876. InitView();
  877. break;
  878. case 2:
  879. Annote.Reset();
  880. InitAnnote();
  881. break;
  882. default:
  883. break;
  884. }
  885. }
  886. /// <summary>
  887. /// 全部重置
  888. /// </summary>
  889. private void resetAll()
  890. {
  891. View.Reset();
  892. Descript.Reset();
  893. Annote.Reset();
  894. InitAnnote();
  895. InitView();
  896. }
  897. public bool CanCloseDialog()
  898. {
  899. return true;
  900. }
  901. public void OnDialogClosed()
  902. {
  903. try
  904. {
  905. View.Save();
  906. Annote.Save();
  907. Descript.Save();
  908. Win32Helper.RegisterDefaultApp(IsDefualtApp);
  909. Settings.Default.Save();
  910. RequestClose.Invoke(new DialogResult());
  911. }
  912. catch { }
  913. }
  914. public void OnDialogOpened(IDialogParameters parameters)
  915. {
  916. }
  917. }
  918. }