DescriptionModel.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. using PDF_Office.Properties;
  2. using PDFSettings;
  3. using Prism.Mvvm;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace PDF_Office.Model.SettingsDialog
  10. {
  11. public class DescriptionModel:BindableBase
  12. {
  13. private bool openUnClosedFileWhenOpen;
  14. public bool OpenUnClosedFileWhenOpen
  15. {
  16. get { return openUnClosedFileWhenOpen; }
  17. set
  18. {
  19. SetProperty(ref openUnClosedFileWhenOpen, value);
  20. }
  21. }
  22. private bool recoveryViewWhenOpen;
  23. public bool RecoveryViewWhenOpen
  24. {
  25. get { return recoveryViewWhenOpen; }
  26. set
  27. {
  28. SetProperty(ref recoveryViewWhenOpen, value);
  29. }
  30. }
  31. private int fileCountInRecentFiles;
  32. public int FileCountInRecentFiles
  33. {
  34. get { return fileCountInRecentFiles; }
  35. set
  36. {
  37. SetProperty(ref fileCountInRecentFiles, value);
  38. }
  39. }
  40. private bool autoSave;
  41. public bool AutoSave
  42. {
  43. get { return autoSave; }
  44. set
  45. {
  46. SetProperty(ref autoSave, value);
  47. }
  48. }
  49. private int autoSaveInterval;
  50. public int AutoSaveInterval
  51. {
  52. get { return autoSaveInterval; }
  53. set
  54. {
  55. SetProperty(ref autoSaveInterval, value);
  56. }
  57. }
  58. private bool showSaveWhenClose;
  59. public bool ShowSaveWhenClose
  60. {
  61. get { return showSaveWhenClose; }
  62. set
  63. {
  64. SetProperty(ref showSaveWhenClose, value);
  65. }
  66. }
  67. private bool notShowSaveWhenClose;
  68. public bool NotShowSaveWhenClose
  69. {
  70. get { return notShowSaveWhenClose; }
  71. set
  72. {
  73. SetProperty(ref notShowSaveWhenClose, value);
  74. }
  75. }
  76. private bool autoScanImageFile;
  77. public bool AutoScanImageFile
  78. {
  79. get { return autoScanImageFile; }
  80. set
  81. {
  82. SetProperty(ref autoScanImageFile, value);
  83. }
  84. }
  85. private bool tipScanImageFile;
  86. public bool TipScanImageFile
  87. {
  88. get { return tipScanImageFile; }
  89. set
  90. {
  91. SetProperty(ref tipScanImageFile, value);
  92. }
  93. }
  94. private string author;
  95. public string Author
  96. {
  97. get { return author; }
  98. set
  99. {
  100. SetProperty(ref author, value);
  101. }
  102. }
  103. public DescriptionModel()
  104. {
  105. InitFromSettings();
  106. }
  107. public void Reset()
  108. {
  109. InitFromSettings();
  110. }
  111. /// <summary>
  112. /// 保存配置到缓存 外面需要统一调用一次settngs.save
  113. /// </summary>
  114. public void Save()
  115. {
  116. DescriptionPropertyClass description = new DescriptionPropertyClass();
  117. description.OpenUnClosedFileWhenOpen = this.OpenUnClosedFileWhenOpen;
  118. description.RecoveryViewWhenOpen = this.RecoveryViewWhenOpen;
  119. description.FileCountInRecentFiles = this.FileCountInRecentFiles;
  120. description.AutoSave = this.AutoSave;
  121. description.AutoSaveInterval = this.AutoSaveInterval;
  122. description.ShowSaveWhenClose = this.ShowSaveWhenClose;
  123. description.NotShowSaveWhenClose = this.NotShowSaveWhenClose;
  124. description.AutoScanImageFile = this.AutoScanImageFile;
  125. description.TipScanImageFile = this.TipScanImageFile;
  126. description.Author = this.Author;
  127. Settings.Default.AppProperties.Description = description;
  128. }
  129. /// <summary>
  130. /// 从缓存读取配置
  131. /// </summary>
  132. private void InitFromSettings()
  133. {
  134. var description = Settings.Default.AppProperties.Description;
  135. this.OpenUnClosedFileWhenOpen = description.OpenUnClosedFileWhenOpen;
  136. this.RecoveryViewWhenOpen = description.RecoveryViewWhenOpen;
  137. this.FileCountInRecentFiles = description.FileCountInRecentFiles;
  138. this.AutoSave = description.AutoSave;
  139. this.AutoSaveInterval = description.AutoSaveInterval;
  140. this.ShowSaveWhenClose = description.ShowSaveWhenClose;
  141. this.NotShowSaveWhenClose = description.NotShowSaveWhenClose;
  142. this.AutoScanImageFile = description.AutoScanImageFile;
  143. this.TipScanImageFile = description.TipScanImageFile;
  144. this.Author = description.Author;
  145. }
  146. }
  147. }