DescriptionModel.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. using PDF_Master.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_Master.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. /// <summary>
  108. /// 重置
  109. /// </summary>
  110. public void Reset()
  111. {
  112. var description = new DescriptionPropertyClass();
  113. this.OpenUnClosedFileWhenOpen = description.OpenUnClosedFileWhenOpen;
  114. this.RecoveryViewWhenOpen = description.RecoveryViewWhenOpen;
  115. this.FileCountInRecentFiles = description.FileCountInRecentFiles;
  116. this.AutoSave = description.AutoSave;
  117. this.AutoSaveInterval = description.AutoSaveInterval;
  118. this.ShowSaveWhenClose = description.ShowSaveWhenClose;
  119. this.NotShowSaveWhenClose = description.NotShowSaveWhenClose;
  120. this.AutoScanImageFile = description.AutoScanImageFile;
  121. this.TipScanImageFile = description.TipScanImageFile;
  122. this.Author = description.Author;
  123. }
  124. /// <summary>
  125. /// 保存配置到缓存 外面需要统一调用一次settngs.save
  126. /// </summary>
  127. public void Save()
  128. {
  129. DescriptionPropertyClass description = new DescriptionPropertyClass();
  130. description.OpenUnClosedFileWhenOpen = this.OpenUnClosedFileWhenOpen;
  131. description.RecoveryViewWhenOpen = this.RecoveryViewWhenOpen;
  132. description.FileCountInRecentFiles = this.FileCountInRecentFiles;
  133. description.AutoSave = this.AutoSave;
  134. description.AutoSaveInterval = this.AutoSaveInterval;
  135. description.ShowSaveWhenClose = this.ShowSaveWhenClose;
  136. description.NotShowSaveWhenClose = this.NotShowSaveWhenClose;
  137. description.AutoScanImageFile = this.AutoScanImageFile;
  138. description.TipScanImageFile = this.TipScanImageFile;
  139. description.Author = this.Author;
  140. Settings.Default.AppProperties.Description = description;
  141. }
  142. /// <summary>
  143. /// 从缓存读取配置
  144. /// </summary>
  145. private void InitFromSettings()
  146. {
  147. var description = Settings.Default.AppProperties.Description;
  148. this.OpenUnClosedFileWhenOpen = description.OpenUnClosedFileWhenOpen;
  149. this.RecoveryViewWhenOpen = description.RecoveryViewWhenOpen;
  150. this.FileCountInRecentFiles = description.FileCountInRecentFiles;
  151. this.AutoSave = description.AutoSave;
  152. this.AutoSaveInterval = description.AutoSaveInterval;
  153. this.ShowSaveWhenClose = description.ShowSaveWhenClose;
  154. this.NotShowSaveWhenClose = description.NotShowSaveWhenClose;
  155. this.AutoScanImageFile = description.AutoScanImageFile;
  156. this.TipScanImageFile = description.TipScanImageFile;
  157. this.Author = description.Author;
  158. }
  159. }
  160. }