AppConfig.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  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. private bool selfStartUp = true; //开机自启动设置
  50. private bool selfStartUped = false; //是否已设置
  51. private bool pmModel = false; //性能模式
  52. #region GetSet
  53. public bool PMModel
  54. {
  55. get
  56. {
  57. return pmModel;
  58. }
  59. set
  60. {
  61. pmModel = value;
  62. OnPropertyChanged("PMModel");
  63. }
  64. }
  65. public bool SelfStartUped
  66. {
  67. get
  68. {
  69. return selfStartUped;
  70. }
  71. set
  72. {
  73. selfStartUped = value;
  74. OnPropertyChanged("SelfStartUped");
  75. }
  76. }
  77. public bool SelfStartUp
  78. {
  79. get
  80. {
  81. return selfStartUp;
  82. }
  83. set
  84. {
  85. selfStartUp = value;
  86. selfStartUped = true;
  87. OnPropertyChanged("SelfStartUp");
  88. }
  89. }
  90. public Key ToDoHotkey
  91. {
  92. get
  93. {
  94. return toDoHotkey;
  95. }
  96. set
  97. {
  98. toDoHotkey = value;
  99. OnPropertyChanged("ToDoHotkey");
  100. }
  101. }
  102. public HotkeyModifiers ToDoHotkeyModifiers
  103. {
  104. get
  105. {
  106. return toDoHotkeyModifiers;
  107. }
  108. set
  109. {
  110. toDoHotkeyModifiers = value;
  111. OnPropertyChanged("ToDoHotkeyModifiers");
  112. }
  113. }
  114. public string ToDoHotkeyStr
  115. {
  116. get
  117. {
  118. return toDoHotkeyStr;
  119. }
  120. set
  121. {
  122. toDoHotkeyStr = value;
  123. OnPropertyChanged("ToDoHotkeyStr");
  124. }
  125. }
  126. public UpdateType UpdateType
  127. {
  128. get
  129. {
  130. return updateType;
  131. }
  132. set
  133. {
  134. updateType = value;
  135. OnPropertyChanged("UpdateType");
  136. }
  137. }
  138. public double BlurValue
  139. {
  140. get
  141. {
  142. return blurValue;
  143. }
  144. set
  145. {
  146. blurValue = value;
  147. OnPropertyChanged("BlurValue");
  148. }
  149. }
  150. public bool BlurEffect
  151. {
  152. get
  153. {
  154. return blurEffect;
  155. }
  156. set
  157. {
  158. blurEffect = value;
  159. if (blurEffect)
  160. {
  161. BlurValue = 100;
  162. } else
  163. {
  164. BlurValue = 0;
  165. }
  166. OnPropertyChanged("BlurEffect");
  167. }
  168. }
  169. public string CustomIconUrl
  170. {
  171. get
  172. {
  173. return customIconUrl;
  174. }
  175. set
  176. {
  177. customIconUrl = value;
  178. OnPropertyChanged("CustomIconUrl");
  179. }
  180. }
  181. public string CustomIconJsonUrl
  182. {
  183. get
  184. {
  185. return customIconJsonUrl;
  186. }
  187. set
  188. {
  189. customIconJsonUrl = value;
  190. OnPropertyChanged("CustomIconJsonUrl");
  191. }
  192. }
  193. public Key Hotkey
  194. {
  195. get
  196. {
  197. return hotkey;
  198. }
  199. set
  200. {
  201. hotkey = value;
  202. OnPropertyChanged("Hotkey");
  203. }
  204. }
  205. public string HotkeyStr
  206. {
  207. get
  208. {
  209. return hotkeyStr;
  210. }
  211. set
  212. {
  213. hotkeyStr = value;
  214. OnPropertyChanged("HotkeyStr");
  215. }
  216. }
  217. public HotkeyModifiers HotkeyModifiers
  218. {
  219. get
  220. {
  221. return hotkeyModifiers;
  222. }
  223. set
  224. {
  225. hotkeyModifiers = value;
  226. OnPropertyChanged("HotkeyModifiers");
  227. }
  228. }
  229. public ObservableCollection<IconInfo> SelectedMenuIcons
  230. {
  231. get
  232. {
  233. return selectedMenuIcons;
  234. }
  235. set
  236. {
  237. selectedMenuIcons = value;
  238. OnPropertyChanged("SelectedMenuIcons");
  239. }
  240. }
  241. public int PannelCornerRadius
  242. {
  243. get
  244. {
  245. return pannelCornerRadius;
  246. }
  247. set
  248. {
  249. pannelCornerRadius = value;
  250. OnPropertyChanged("pannelCornerRadius");
  251. }
  252. }
  253. public int PannelOpacity
  254. {
  255. get
  256. {
  257. return pannelOpacity;
  258. }
  259. set
  260. {
  261. pannelOpacity = value;
  262. OnPropertyChanged("PannelOpacity");
  263. }
  264. }
  265. public int BgOpacity
  266. {
  267. get
  268. {
  269. return bgOpacity;
  270. }
  271. set
  272. {
  273. bgOpacity = value;
  274. OnPropertyChanged("BgOpacity");
  275. }
  276. }
  277. public int CardOpacity
  278. {
  279. get
  280. {
  281. return cardOpacity;
  282. }
  283. set
  284. {
  285. cardOpacity = value;
  286. OnPropertyChanged("CardOpacity");
  287. }
  288. }
  289. public string BacImgName
  290. {
  291. get
  292. {
  293. return bacImgName;
  294. }
  295. set
  296. {
  297. bacImgName = value;
  298. OnPropertyChanged("BacImgName");
  299. }
  300. }
  301. public byte[] ImageByteArr
  302. {
  303. get
  304. {
  305. return imageByteArr;
  306. }
  307. set
  308. {
  309. imageByteArr = value;
  310. OnPropertyChanged("ImageByteArr");
  311. }
  312. }
  313. public BitmapImage BitmapImage
  314. {
  315. get
  316. {
  317. if (imageByteArr == null || imageByteArr.Length == 0)
  318. {
  319. bacImgName = "系统默认";
  320. //Image image = ImageUtil.ByteArrayToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64));
  321. return ImageUtil.ByteArrToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64));
  322. } else
  323. {
  324. return ImageUtil.ByteArrToImage(ImageByteArr);
  325. }
  326. }
  327. set
  328. {
  329. bitmapImage = value;
  330. imageByteArr = ImageUtil.BitmapImageToByte(bitmapImage);
  331. OnPropertyChanged("BitmapImage");
  332. }
  333. }
  334. public bool StartedShowPanel
  335. {
  336. get
  337. {
  338. return startedShowPanel;
  339. }
  340. set
  341. {
  342. startedShowPanel = value;
  343. OnPropertyChanged("StartedShowPanel");
  344. }
  345. }
  346. public AppHideType AppHideType
  347. {
  348. get
  349. {
  350. return appHideType;
  351. }
  352. set
  353. {
  354. appHideType = value;
  355. OnPropertyChanged("AppHideType");
  356. }
  357. }
  358. public Visibility ConfigIconVisible
  359. {
  360. get
  361. {
  362. return configIconVisible;
  363. }
  364. set
  365. {
  366. configIconVisible = value;
  367. OnPropertyChanged("ConfigIconVisible");
  368. }
  369. }
  370. public bool FollowMouse
  371. {
  372. get
  373. {
  374. return followMouse;
  375. }
  376. set
  377. {
  378. followMouse = value;
  379. OnPropertyChanged("FollowMouse");
  380. }
  381. }
  382. public int SelectedMenuIndex
  383. {
  384. get
  385. {
  386. return selectedMenuIndex;
  387. }
  388. set
  389. {
  390. selectedMenuIndex = value;
  391. OnPropertyChanged("SelectedMenuIndex");
  392. }
  393. }
  394. public SortType MenuSortType
  395. {
  396. get
  397. {
  398. return menuSortType;
  399. }
  400. set
  401. {
  402. menuSortType = value;
  403. OnPropertyChanged("MenuSortType");
  404. }
  405. }
  406. public SortType IconSortType
  407. {
  408. get
  409. {
  410. return iconSortType;
  411. }
  412. set
  413. {
  414. iconSortType = value;
  415. OnPropertyChanged("IconSortType");
  416. }
  417. }
  418. public double WindowWidth
  419. {
  420. get
  421. {
  422. return windowWidth;
  423. }
  424. set
  425. {
  426. windowWidth = value;
  427. OnPropertyChanged("WindowWidth");
  428. }
  429. }
  430. public double WindowHeight
  431. {
  432. get
  433. {
  434. return windowHeight;
  435. }
  436. set
  437. {
  438. windowHeight = value;
  439. OnPropertyChanged("WindowHeight");
  440. }
  441. }
  442. public double MenuCardWidth
  443. {
  444. get
  445. {
  446. return menuCardWidth;
  447. }
  448. set
  449. {
  450. menuCardWidth = value;
  451. OnPropertyChanged("MenuCardWidth");
  452. }
  453. }
  454. [field: NonSerializedAttribute()]
  455. public event PropertyChangedEventHandler PropertyChanged;
  456. private void OnPropertyChanged(string propertyName)
  457. {
  458. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  459. CommonCode.SaveAppData(MainWindow.appData);
  460. }
  461. #endregion
  462. }
  463. }