AppConfig.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. 
  2. using GeekDesk.Constant;
  3. using GeekDesk.Util;
  4. using System;
  5. using System.Collections.ObjectModel;
  6. using System.ComponentModel;
  7. using System.Windows;
  8. using System.Windows.Input;
  9. using System.Windows.Media.Imaging;
  10. /// <summary>
  11. /// 程序设置
  12. /// </summary>
  13. namespace GeekDesk.ViewModel
  14. {
  15. [Serializable]
  16. public class AppConfig : INotifyPropertyChanged
  17. {
  18. private SortType menuSortType = SortType.CUSTOM; //菜单排序类型
  19. private SortType iconSortType = SortType.CUSTOM; //图表排序类型
  20. private double windowWidth = (double)MainWindowEnum.WINDOW_WIDTH; //窗口宽度
  21. private double windowHeight = (double)MainWindowEnum.WINDOW_HEIGHT; //窗口高度
  22. private double menuCardWidth = (double)MainWindowEnum.MENU_CARD_WIDHT;//菜单栏宽度
  23. private int selectedMenuIndex = 0; //上次选中菜单索引
  24. private bool followMouse = true; //面板跟随鼠标 默认是
  25. private Visibility configIconVisible = Visibility.Visible; // 设置按钮是否显示
  26. private AppHideType appHideType = AppHideType.START_EXE; //面板关闭方式 (默认启动程序后)
  27. private bool startedShowPanel = true; //启动时是否显示主面板 默认显示
  28. [field: NonSerialized]
  29. private BitmapImage bitmapImage; //位图
  30. private byte[] imageByteArr; //背景图片 byte数组
  31. private string bacImgName = "系统默认";
  32. private int cardOpacity = 10; //默认0.1的不透明度 此处显示数值 * 100
  33. private int bgOpacity = 100; // 背景图片不透明度 此处显示数值 * 100
  34. private int pannelOpacity = 100; //主面板不透明度 此处显示数值 * 100
  35. private int pannelCornerRadius = 4; //面板圆角 默认4
  36. [field: NonSerialized]
  37. private ObservableCollection<IconInfo> selectedMenuIcons;
  38. private string hotkeyStr = "Ctrl + Q"; //默认启动面板快捷键
  39. private HotkeyModifiers hotkeyModifiers = HotkeyModifiers.MOD_CONTROL; //默认启动面板快捷键
  40. private Key hotkey = Key.Q; //默认启动面板快捷键
  41. private string toDoHotkeyStr; //待办任务快捷键
  42. private HotkeyModifiers toDoHotkeyModifiers; //待办任务快捷键
  43. private Key toDoHotkey; //待办任务快捷键
  44. private string customIconUrl; //自定义图标url
  45. private string customIconJsonUrl; //自定义图标json信息url
  46. private bool blurEffect = false; //毛玻璃效果 默认否
  47. private double blurValue;
  48. private UpdateType updateType = UpdateType.Gitee; //更新源 默认gitee源
  49. #region GetSet
  50. public Key ToDoHotkey
  51. {
  52. get
  53. {
  54. return toDoHotkey;
  55. }
  56. set
  57. {
  58. toDoHotkey = value;
  59. OnPropertyChanged("ToDoHotkey");
  60. }
  61. }
  62. public HotkeyModifiers ToDoHotkeyModifiers
  63. {
  64. get
  65. {
  66. return toDoHotkeyModifiers;
  67. }
  68. set
  69. {
  70. toDoHotkeyModifiers = value;
  71. OnPropertyChanged("ToDoHotkeyModifiers");
  72. }
  73. }
  74. public string ToDoHotkeyStr
  75. {
  76. get
  77. {
  78. return toDoHotkeyStr;
  79. }
  80. set
  81. {
  82. toDoHotkeyStr = value;
  83. OnPropertyChanged("ToDoHotkeyStr");
  84. }
  85. }
  86. public UpdateType UpdateType
  87. {
  88. get
  89. {
  90. return updateType;
  91. }
  92. set
  93. {
  94. updateType = value;
  95. OnPropertyChanged("UpdateType");
  96. }
  97. }
  98. public double BlurValue
  99. {
  100. get
  101. {
  102. return blurValue;
  103. }
  104. set
  105. {
  106. blurValue = value;
  107. OnPropertyChanged("BlurValue");
  108. }
  109. }
  110. public bool BlurEffect
  111. {
  112. get
  113. {
  114. return blurEffect;
  115. }
  116. set
  117. {
  118. blurEffect = value;
  119. if (blurEffect)
  120. {
  121. BlurValue = 100;
  122. } else
  123. {
  124. BlurValue = 0;
  125. }
  126. OnPropertyChanged("BlurEffect");
  127. }
  128. }
  129. public string CustomIconUrl
  130. {
  131. get
  132. {
  133. return customIconUrl;
  134. }
  135. set
  136. {
  137. customIconUrl = value;
  138. OnPropertyChanged("CustomIconUrl");
  139. }
  140. }
  141. public string CustomIconJsonUrl
  142. {
  143. get
  144. {
  145. return customIconJsonUrl;
  146. }
  147. set
  148. {
  149. customIconJsonUrl = value;
  150. OnPropertyChanged("CustomIconJsonUrl");
  151. }
  152. }
  153. public Key Hotkey
  154. {
  155. get
  156. {
  157. return hotkey;
  158. }
  159. set
  160. {
  161. hotkey = value;
  162. OnPropertyChanged("Hotkey");
  163. }
  164. }
  165. public string HotkeyStr
  166. {
  167. get
  168. {
  169. return hotkeyStr;
  170. }
  171. set
  172. {
  173. hotkeyStr = value;
  174. OnPropertyChanged("HotkeyStr");
  175. }
  176. }
  177. public HotkeyModifiers HotkeyModifiers
  178. {
  179. get
  180. {
  181. return hotkeyModifiers;
  182. }
  183. set
  184. {
  185. hotkeyModifiers = value;
  186. OnPropertyChanged("HotkeyModifiers");
  187. }
  188. }
  189. public ObservableCollection<IconInfo> SelectedMenuIcons
  190. {
  191. get
  192. {
  193. return selectedMenuIcons;
  194. }
  195. set
  196. {
  197. selectedMenuIcons = value;
  198. OnPropertyChanged("SelectedMenuIcons");
  199. }
  200. }
  201. public int PannelCornerRadius
  202. {
  203. get
  204. {
  205. return pannelCornerRadius;
  206. }
  207. set
  208. {
  209. pannelCornerRadius = value;
  210. OnPropertyChanged("pannelCornerRadius");
  211. }
  212. }
  213. public int PannelOpacity
  214. {
  215. get
  216. {
  217. return pannelOpacity;
  218. }
  219. set
  220. {
  221. pannelOpacity = value;
  222. OnPropertyChanged("PannelOpacity");
  223. }
  224. }
  225. public int BgOpacity
  226. {
  227. get
  228. {
  229. return bgOpacity;
  230. }
  231. set
  232. {
  233. bgOpacity = value;
  234. OnPropertyChanged("BgOpacity");
  235. }
  236. }
  237. public int CardOpacity
  238. {
  239. get
  240. {
  241. return cardOpacity;
  242. }
  243. set
  244. {
  245. cardOpacity = value;
  246. OnPropertyChanged("CardOpacity");
  247. }
  248. }
  249. public string BacImgName
  250. {
  251. get
  252. {
  253. return bacImgName;
  254. }
  255. set
  256. {
  257. bacImgName = value;
  258. OnPropertyChanged("BacImgName");
  259. }
  260. }
  261. public byte[] ImageByteArr
  262. {
  263. get
  264. {
  265. return imageByteArr;
  266. }
  267. set
  268. {
  269. imageByteArr = value;
  270. OnPropertyChanged("ImageByteArr");
  271. }
  272. }
  273. public BitmapImage BitmapImage
  274. {
  275. get
  276. {
  277. if (imageByteArr == null || imageByteArr.Length == 0)
  278. {
  279. bacImgName = "系统默认";
  280. //Image image = ImageUtil.ByteArrayToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64));
  281. return ImageUtil.ByteArrToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64));
  282. } else
  283. {
  284. return ImageUtil.ByteArrToImage(ImageByteArr);
  285. }
  286. }
  287. set
  288. {
  289. bitmapImage = value;
  290. imageByteArr = ImageUtil.BitmapImageToByte(bitmapImage);
  291. OnPropertyChanged("BitmapImage");
  292. }
  293. }
  294. public bool StartedShowPanel
  295. {
  296. get
  297. {
  298. return startedShowPanel;
  299. }
  300. set
  301. {
  302. startedShowPanel = value;
  303. OnPropertyChanged("StartedShowPanel");
  304. }
  305. }
  306. public AppHideType AppHideType
  307. {
  308. get
  309. {
  310. return appHideType;
  311. }
  312. set
  313. {
  314. appHideType = value;
  315. OnPropertyChanged("AppHideType");
  316. }
  317. }
  318. public Visibility ConfigIconVisible
  319. {
  320. get
  321. {
  322. return configIconVisible;
  323. }
  324. set
  325. {
  326. configIconVisible = value;
  327. OnPropertyChanged("ConfigIconVisible");
  328. }
  329. }
  330. public bool FollowMouse
  331. {
  332. get
  333. {
  334. return followMouse;
  335. }
  336. set
  337. {
  338. followMouse = value;
  339. OnPropertyChanged("FollowMouse");
  340. }
  341. }
  342. public int SelectedMenuIndex
  343. {
  344. get
  345. {
  346. return selectedMenuIndex;
  347. }
  348. set
  349. {
  350. selectedMenuIndex = value;
  351. OnPropertyChanged("SelectedMenuIndex");
  352. }
  353. }
  354. public SortType MenuSortType
  355. {
  356. get
  357. {
  358. return menuSortType;
  359. }
  360. set
  361. {
  362. menuSortType = value;
  363. OnPropertyChanged("MenuSortType");
  364. }
  365. }
  366. public SortType IconSortType
  367. {
  368. get
  369. {
  370. return iconSortType;
  371. }
  372. set
  373. {
  374. iconSortType = value;
  375. OnPropertyChanged("IconSortType");
  376. }
  377. }
  378. public double WindowWidth
  379. {
  380. get
  381. {
  382. return windowWidth;
  383. }
  384. set
  385. {
  386. windowWidth = value;
  387. OnPropertyChanged("WindowWidth");
  388. }
  389. }
  390. public double WindowHeight
  391. {
  392. get
  393. {
  394. return windowHeight;
  395. }
  396. set
  397. {
  398. windowHeight = value;
  399. OnPropertyChanged("WindowHeight");
  400. }
  401. }
  402. public double MenuCardWidth
  403. {
  404. get
  405. {
  406. return menuCardWidth;
  407. }
  408. set
  409. {
  410. menuCardWidth = value;
  411. OnPropertyChanged("MenuCardWidth");
  412. }
  413. }
  414. [field: NonSerializedAttribute()]
  415. public event PropertyChangedEventHandler PropertyChanged;
  416. private void OnPropertyChanged(string propertyName)
  417. {
  418. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  419. CommonCode.SaveAppData(MainWindow.appData);
  420. }
  421. #endregion
  422. }
  423. }