AppConfig.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. 
  2. using GeekDesk.Constant;
  3. using GeekDesk.Util;
  4. using System;
  5. using System.ComponentModel;
  6. using System.Windows;
  7. using System.Windows.Media.Imaging;
  8. /// <summary>
  9. /// 程序设置
  10. /// </summary>
  11. namespace GeekDesk.ViewModel
  12. {
  13. [Serializable]
  14. public class AppConfig : INotifyPropertyChanged
  15. {
  16. private SortType menuSortType = SortType.CUSTOM; //菜单排序类型
  17. private SortType iconSortType = SortType.CUSTOM; //图表排序类型
  18. private double windowWidth = (double)DefaultConstant.WINDOW_WIDTH; //窗口宽度
  19. private double windowHeight = (double)DefaultConstant.WINDOW_HEIGHT; //窗口高度
  20. private double menuCardWidth = (double)DefaultConstant.MENU_CARD_WIDHT;//菜单栏宽度
  21. private int selectedMenuIndex = 0; //上次选中菜单索引
  22. private bool followMouse = true; //面板跟随鼠标 默认是
  23. private Visibility configIconVisible = Visibility.Visible; // 设置按钮是否显示
  24. private AppHideType appHideType = AppHideType.START_EXE; //面板关闭方式 (默认启动程序后)
  25. private bool startedShowPanel = true; //启动时是否显示主面板 默认显示
  26. [field: NonSerialized]
  27. private BitmapImage bitmapImage; //位图
  28. private byte[] imageByteArr; //背景图片 byte数组
  29. private string bacImgName = "系统默认";
  30. #region GetSet
  31. public string BacImgName
  32. {
  33. get
  34. {
  35. return bacImgName;
  36. }
  37. set
  38. {
  39. bacImgName = value;
  40. OnPropertyChanged("BacImgName");
  41. }
  42. }
  43. public byte[] ImageByteArr
  44. {
  45. get
  46. {
  47. return imageByteArr;
  48. }
  49. set
  50. {
  51. imageByteArr = value;
  52. OnPropertyChanged("ImageByteArr");
  53. }
  54. }
  55. public BitmapImage BitmapImage
  56. {
  57. get
  58. {
  59. if (imageByteArr == null || imageByteArr.Length == 0)
  60. {
  61. return ImageUtil.ByteArrToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64));
  62. } else
  63. {
  64. return ImageUtil.ByteArrToImage(ImageByteArr);
  65. }
  66. }
  67. set
  68. {
  69. bitmapImage = value;
  70. imageByteArr = ImageUtil.BitmapImageToByte(bitmapImage);
  71. OnPropertyChanged("BitmapImage");
  72. }
  73. }
  74. public bool StartedShowPanel
  75. {
  76. get
  77. {
  78. return startedShowPanel;
  79. }
  80. set
  81. {
  82. startedShowPanel = value;
  83. OnPropertyChanged("StartedShowPanel");
  84. }
  85. }
  86. public AppHideType AppHideType
  87. {
  88. get
  89. {
  90. return appHideType;
  91. }
  92. set
  93. {
  94. appHideType = value;
  95. OnPropertyChanged("AppHideType");
  96. }
  97. }
  98. public Visibility ConfigIconVisible
  99. {
  100. get
  101. {
  102. return configIconVisible;
  103. }
  104. set
  105. {
  106. configIconVisible = value;
  107. OnPropertyChanged("ConfigIconVisible");
  108. }
  109. }
  110. public bool FollowMouse
  111. {
  112. get
  113. {
  114. return followMouse;
  115. }
  116. set
  117. {
  118. followMouse = value;
  119. OnPropertyChanged("FollowMouse");
  120. }
  121. }
  122. public int SelectedMenuIndex
  123. {
  124. get
  125. {
  126. return selectedMenuIndex;
  127. }
  128. set
  129. {
  130. selectedMenuIndex = value;
  131. OnPropertyChanged("SelectedMenuIndex");
  132. }
  133. }
  134. public SortType MenuSortType
  135. {
  136. get
  137. {
  138. return menuSortType;
  139. }
  140. set
  141. {
  142. menuSortType = value;
  143. OnPropertyChanged("MenuSortType");
  144. }
  145. }
  146. public SortType IconSortType
  147. {
  148. get
  149. {
  150. return iconSortType;
  151. }
  152. set
  153. {
  154. iconSortType = value;
  155. OnPropertyChanged("IconSortType");
  156. }
  157. }
  158. public double WindowWidth
  159. {
  160. get
  161. {
  162. return windowWidth;
  163. }
  164. set
  165. {
  166. windowWidth = value;
  167. OnPropertyChanged("WindowWidth");
  168. }
  169. }
  170. public double WindowHeight
  171. {
  172. get
  173. {
  174. return windowHeight;
  175. }
  176. set
  177. {
  178. windowHeight = value;
  179. OnPropertyChanged("WindowHeight");
  180. }
  181. }
  182. public double MenuCardWidth
  183. {
  184. get
  185. {
  186. return menuCardWidth;
  187. }
  188. set
  189. {
  190. menuCardWidth = value;
  191. OnPropertyChanged("MenuCardWidth");
  192. }
  193. }
  194. [field: NonSerializedAttribute()]
  195. public event PropertyChangedEventHandler PropertyChanged;
  196. private void OnPropertyChanged(string propertyName)
  197. {
  198. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  199. CommonCode.SaveAppData(MainWindow.appData);
  200. }
  201. #endregion
  202. }
  203. }