1
0

AppConfig.cs 9.3 KB

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