AppConfig.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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 customIconUrl; //自定义图标url
  42. private string customIconJsonUrl; //自定义图标json信息url
  43. private bool blurEffect = false; //毛玻璃效果 默认否
  44. private double blurValue;
  45. #region GetSet
  46. public double BlurValue
  47. {
  48. get
  49. {
  50. return blurValue;
  51. }
  52. set
  53. {
  54. blurValue = value;
  55. OnPropertyChanged("BlurValue");
  56. }
  57. }
  58. public bool BlurEffect
  59. {
  60. get
  61. {
  62. return blurEffect;
  63. }
  64. set
  65. {
  66. blurEffect = value;
  67. if (blurEffect)
  68. {
  69. BlurValue = 100;
  70. } else
  71. {
  72. BlurValue = 0;
  73. }
  74. OnPropertyChanged("BlurEffect");
  75. }
  76. }
  77. public string CustomIconUrl
  78. {
  79. get
  80. {
  81. return customIconUrl;
  82. }
  83. set
  84. {
  85. customIconUrl = value;
  86. OnPropertyChanged("CustomIconUrl");
  87. }
  88. }
  89. public string CustomIconJsonUrl
  90. {
  91. get
  92. {
  93. return customIconJsonUrl;
  94. }
  95. set
  96. {
  97. customIconJsonUrl = value;
  98. OnPropertyChanged("CustomIconJsonUrl");
  99. }
  100. }
  101. public Key Hotkey
  102. {
  103. get
  104. {
  105. return hotkey;
  106. }
  107. set
  108. {
  109. hotkey = value;
  110. OnPropertyChanged("Hotkey");
  111. }
  112. }
  113. public string HotkeyStr
  114. {
  115. get
  116. {
  117. return hotkeyStr;
  118. }
  119. set
  120. {
  121. hotkeyStr = value;
  122. OnPropertyChanged("HotkeyStr");
  123. }
  124. }
  125. public HotkeyModifiers HotkeyModifiers
  126. {
  127. get
  128. {
  129. return hotkeyModifiers;
  130. }
  131. set
  132. {
  133. hotkeyModifiers = value;
  134. OnPropertyChanged("HotkeyModifiers");
  135. }
  136. }
  137. public ObservableCollection<IconInfo> SelectedMenuIcons
  138. {
  139. get
  140. {
  141. return selectedMenuIcons;
  142. }
  143. set
  144. {
  145. selectedMenuIcons = value;
  146. OnPropertyChanged("SelectedMenuIcons");
  147. }
  148. }
  149. public int PannelCornerRadius
  150. {
  151. get
  152. {
  153. return pannelCornerRadius;
  154. }
  155. set
  156. {
  157. pannelCornerRadius = value;
  158. OnPropertyChanged("pannelCornerRadius");
  159. }
  160. }
  161. public int PannelOpacity
  162. {
  163. get
  164. {
  165. return pannelOpacity;
  166. }
  167. set
  168. {
  169. pannelOpacity = value;
  170. OnPropertyChanged("PannelOpacity");
  171. }
  172. }
  173. public int BgOpacity
  174. {
  175. get
  176. {
  177. return bgOpacity;
  178. }
  179. set
  180. {
  181. bgOpacity = value;
  182. OnPropertyChanged("BgOpacity");
  183. }
  184. }
  185. public int CardOpacity
  186. {
  187. get
  188. {
  189. return cardOpacity;
  190. }
  191. set
  192. {
  193. cardOpacity = value;
  194. OnPropertyChanged("CardOpacity");
  195. }
  196. }
  197. public string BacImgName
  198. {
  199. get
  200. {
  201. return bacImgName;
  202. }
  203. set
  204. {
  205. bacImgName = value;
  206. OnPropertyChanged("BacImgName");
  207. }
  208. }
  209. public byte[] ImageByteArr
  210. {
  211. get
  212. {
  213. return imageByteArr;
  214. }
  215. set
  216. {
  217. imageByteArr = value;
  218. OnPropertyChanged("ImageByteArr");
  219. }
  220. }
  221. public BitmapImage BitmapImage
  222. {
  223. get
  224. {
  225. if (imageByteArr == null || imageByteArr.Length == 0)
  226. {
  227. bacImgName = "系统默认";
  228. //Image image = ImageUtil.ByteArrayToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64));
  229. return ImageUtil.ByteArrToImage(Convert.FromBase64String(Constants.DEFAULT_BAC_IMAGE_BASE64));
  230. } else
  231. {
  232. return ImageUtil.ByteArrToImage(ImageByteArr);
  233. }
  234. }
  235. set
  236. {
  237. bitmapImage = value;
  238. imageByteArr = ImageUtil.BitmapImageToByte(bitmapImage);
  239. OnPropertyChanged("BitmapImage");
  240. }
  241. }
  242. public bool StartedShowPanel
  243. {
  244. get
  245. {
  246. return startedShowPanel;
  247. }
  248. set
  249. {
  250. startedShowPanel = value;
  251. OnPropertyChanged("StartedShowPanel");
  252. }
  253. }
  254. public AppHideType AppHideType
  255. {
  256. get
  257. {
  258. return appHideType;
  259. }
  260. set
  261. {
  262. appHideType = value;
  263. OnPropertyChanged("AppHideType");
  264. }
  265. }
  266. public Visibility ConfigIconVisible
  267. {
  268. get
  269. {
  270. return configIconVisible;
  271. }
  272. set
  273. {
  274. configIconVisible = value;
  275. OnPropertyChanged("ConfigIconVisible");
  276. }
  277. }
  278. public bool FollowMouse
  279. {
  280. get
  281. {
  282. return followMouse;
  283. }
  284. set
  285. {
  286. followMouse = value;
  287. OnPropertyChanged("FollowMouse");
  288. }
  289. }
  290. public int SelectedMenuIndex
  291. {
  292. get
  293. {
  294. return selectedMenuIndex;
  295. }
  296. set
  297. {
  298. selectedMenuIndex = value;
  299. OnPropertyChanged("SelectedMenuIndex");
  300. }
  301. }
  302. public SortType MenuSortType
  303. {
  304. get
  305. {
  306. return menuSortType;
  307. }
  308. set
  309. {
  310. menuSortType = value;
  311. OnPropertyChanged("MenuSortType");
  312. }
  313. }
  314. public SortType IconSortType
  315. {
  316. get
  317. {
  318. return iconSortType;
  319. }
  320. set
  321. {
  322. iconSortType = value;
  323. OnPropertyChanged("IconSortType");
  324. }
  325. }
  326. public double WindowWidth
  327. {
  328. get
  329. {
  330. return windowWidth;
  331. }
  332. set
  333. {
  334. windowWidth = value;
  335. OnPropertyChanged("WindowWidth");
  336. }
  337. }
  338. public double WindowHeight
  339. {
  340. get
  341. {
  342. return windowHeight;
  343. }
  344. set
  345. {
  346. windowHeight = value;
  347. OnPropertyChanged("WindowHeight");
  348. }
  349. }
  350. public double MenuCardWidth
  351. {
  352. get
  353. {
  354. return menuCardWidth;
  355. }
  356. set
  357. {
  358. menuCardWidth = value;
  359. OnPropertyChanged("MenuCardWidth");
  360. }
  361. }
  362. [field: NonSerializedAttribute()]
  363. public event PropertyChangedEventHandler PropertyChanged;
  364. private void OnPropertyChanged(string propertyName)
  365. {
  366. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  367. CommonCode.SaveAppData(MainWindow.appData);
  368. }
  369. #endregion
  370. }
  371. }