SettingsDialogViewModel.cs 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043
  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. public SettingsDialogViewModel()
  735. {
  736. InitString();
  737. Annote = new AnnotateModel();
  738. Descript = new DescriptionModel();
  739. View = new InitialVIewModel();
  740. PageViewList = new ObservableCollection<string>();
  741. AnnoteFamilyList = new ObservableCollection<string>();
  742. ZoomModeList = new ObservableCollection<string>();
  743. ResetAllCommand = new DelegateCommand(resetAll);
  744. ResetCommand = new DelegateCommand(reset);
  745. InitAnnoteFamily();
  746. InitPageViews();
  747. InitZoomMode();
  748. //根据缓存还原下拉框 单选等
  749. InitAnnote();
  750. InitView();
  751. //判断是否以管理员身份运行
  752. IsSetDefualtAppEnable = Win32Helper.IsRunAsAdmin();
  753. IsDefualtApp = Win32Helper.IsDefaultApp();
  754. }
  755. private void InitView()
  756. {
  757. //页面模式下拉框
  758. PageViewSelctedIndex = (int)View.PageView - 1;
  759. //缩放模式下拉框
  760. switch (View.ZoomMode)
  761. {
  762. case ComPDFKitViewer.FitMode.FitWidth:
  763. ZoomModeSelectedIndex = 0;
  764. break;
  765. case ComPDFKitViewer.FitMode.FitHeight:
  766. ZoomModeSelectedIndex = 1;
  767. break;
  768. case ComPDFKitViewer.FitMode.FitSize:
  769. zoomModeSelectedIndex = 2;
  770. break;
  771. case ComPDFKitViewer.FitMode.FitFree:
  772. //TODO:
  773. break;
  774. default:
  775. break;
  776. }
  777. }
  778. private void InitAnnote()
  779. {
  780. //注释对齐方式
  781. switch (Annote.TextAlign)
  782. {
  783. case System.Windows.TextAlignment.Left:
  784. LeftSelected = true;
  785. break;
  786. case System.Windows.TextAlignment.Right:
  787. RightSelected = true;
  788. break;
  789. case System.Windows.TextAlignment.Center:
  790. CenterSelected = true;
  791. break;
  792. case System.Windows.TextAlignment.Justify:
  793. default:
  794. StrechSelected = true;
  795. break;
  796. }
  797. //文本注释字体
  798. if(Annote.TextFontFamaily== "Courier New")
  799. {
  800. AnnoteSelectedIndex = 0;
  801. }
  802. else if(Annote.TextFontFamaily== "Helvetica")
  803. {
  804. AnnoteSelectedIndex = 1;
  805. }
  806. else
  807. {
  808. AnnoteSelectedIndex = 2;
  809. }
  810. //便签注释字体
  811. if (Annote.AnchoredFamaily == "Courier")
  812. {
  813. NoteSelectedIndex = 0;
  814. }
  815. else if (Annote.AnchoredFamaily == "Helvetica")
  816. {
  817. NoteSelectedIndex = 1;
  818. }
  819. else
  820. {
  821. NoteSelectedIndex = 2;
  822. }
  823. }
  824. private void InitPageViews()
  825. {
  826. PageViewList.Clear();
  827. PageViewList.Add(Settings_Display_Singlepage);
  828. PageViewList.Add(Settings_Display_Singlepagecon);
  829. PageViewList.Add(Settings_Display_Twopage);
  830. PageViewList.Add(Settings_Display_Twopagecon);
  831. PageViewList.Add(Settings_Display_Bookmode);
  832. PageViewList.Add(Settings_Display_Bookmodecon);
  833. }
  834. private void InitZoomMode()
  835. {
  836. ZoomModeList.Clear();
  837. ZoomModeList.Add(Settings_Display_Fitwidth);
  838. ZoomModeList.Add(Settings_Display_Fitpage);
  839. ZoomModeList.Add(Settings_Display_Actualsize);
  840. }
  841. private void InitAnnoteFamily()
  842. {
  843. AnnoteFamilyList.Clear();
  844. AnnoteFamilyList.Add("Courier New");
  845. AnnoteFamilyList.Add("Arial");
  846. AnnoteFamilyList.Add("Times New Roman");
  847. }
  848. /// <summary>
  849. /// 重置
  850. /// </summary>
  851. private void reset()
  852. {
  853. switch (ModeSelectedIndex)
  854. {
  855. case 0:
  856. Descript.Reset();
  857. break;
  858. case 1:
  859. View.Reset();
  860. InitView();
  861. break;
  862. case 2:
  863. Annote.Reset();
  864. InitAnnote();
  865. break;
  866. default:
  867. break;
  868. }
  869. }
  870. /// <summary>
  871. /// 全部重置
  872. /// </summary>
  873. private void resetAll()
  874. {
  875. View.Reset();
  876. Descript.Reset();
  877. Annote.Reset();
  878. InitAnnote();
  879. InitView();
  880. }
  881. public bool CanCloseDialog()
  882. {
  883. return true;
  884. }
  885. public void OnDialogClosed()
  886. {
  887. try
  888. {
  889. View.Save();
  890. Annote.Save();
  891. Descript.Save();
  892. Win32Helper.RegisterDefaultApp(IsDefualtApp);
  893. Settings.Default.Save();
  894. }
  895. catch { }
  896. }
  897. public void OnDialogOpened(IDialogParameters parameters)
  898. {
  899. }
  900. }
  901. }