IconInfo.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. using GeekDesk.Constant;
  2. using GeekDesk.Util;
  3. using System;
  4. using System.ComponentModel;
  5. using System.Windows.Media.Imaging;
  6. /// <summary>
  7. /// 图标信息
  8. /// </summary>
  9. namespace GeekDesk.ViewModel
  10. {
  11. [Serializable]
  12. public class IconInfo : INotifyPropertyChanged
  13. {
  14. private string path; //路径
  15. private string name; //文件名
  16. private int count = 0; //打开次数
  17. [field: NonSerialized]
  18. private BitmapImage bitmapImage; //位图
  19. private byte[] imageByteArr; //图片 byte数组
  20. private string content; //显示信息
  21. private bool adminStartUp = false; //始终管理员方式启动 默认否
  22. private byte[] defaultImage; //默认图标
  23. private string startArg; //启动参数
  24. private string lnkPath;
  25. private string relativePath; //相对路径
  26. private IconType iconType = IconType.OTHER;
  27. public string RelativePath_NoWrite
  28. {
  29. get
  30. {
  31. return relativePath;
  32. }
  33. set
  34. {
  35. relativePath = value;
  36. }
  37. }
  38. public string RelativePath
  39. {
  40. get
  41. {
  42. return relativePath;
  43. }
  44. set
  45. {
  46. relativePath = value;
  47. OnPropertyChanged("RelativePath");
  48. }
  49. }
  50. public string LnkPath_NoWrite
  51. {
  52. get
  53. {
  54. return lnkPath;
  55. }
  56. set
  57. {
  58. lnkPath = value;
  59. }
  60. }
  61. public string LnkPath
  62. {
  63. get
  64. {
  65. return lnkPath;
  66. }
  67. set
  68. {
  69. lnkPath = value;
  70. OnPropertyChanged("LnkPath");
  71. }
  72. }
  73. public string StartArg
  74. {
  75. get
  76. {
  77. return startArg;
  78. }
  79. set
  80. {
  81. startArg = value;
  82. OnPropertyChanged("StartArg");
  83. }
  84. }
  85. public string StartArg_NoWrite
  86. {
  87. get
  88. {
  89. return startArg;
  90. }
  91. set
  92. {
  93. startArg = value;
  94. }
  95. }
  96. public IconType IconType
  97. {
  98. get
  99. {
  100. if (iconType == 0) return IconType.OTHER;
  101. return iconType;
  102. }
  103. set
  104. {
  105. iconType = value;
  106. OnPropertyChanged("IconType");
  107. }
  108. }
  109. public byte[] DefaultImage
  110. {
  111. get
  112. {
  113. return defaultImage;
  114. }
  115. set
  116. {
  117. defaultImage = value;
  118. OnPropertyChanged("DefaultImage");
  119. }
  120. }
  121. public byte[] DefaultImage_NoWrite
  122. {
  123. get
  124. {
  125. return defaultImage;
  126. }
  127. set
  128. {
  129. defaultImage = value;
  130. }
  131. }
  132. public bool AdminStartUp
  133. {
  134. get
  135. {
  136. return adminStartUp;
  137. }
  138. set
  139. {
  140. adminStartUp = value;
  141. OnPropertyChanged("AdminStartUp");
  142. }
  143. }
  144. public int Count
  145. {
  146. get
  147. {
  148. return count;
  149. }
  150. set
  151. {
  152. count = value;
  153. if (StringUtil.IsEmpty(Path))
  154. {
  155. Content = Name + "\n使用次数: " + Count;
  156. }
  157. else
  158. {
  159. Content = Path + "\n" + Name + "\n使用次数: " + Count;
  160. }
  161. OnPropertyChanged("Count");
  162. }
  163. }
  164. public string Name
  165. {
  166. get
  167. {
  168. return name;
  169. }
  170. set
  171. {
  172. name = value;
  173. if (StringUtil.IsEmpty(Path))
  174. {
  175. Content = Name + "\n使用次数: " + Count;
  176. }
  177. else
  178. {
  179. Content = Path + "\n" + Name + "\n使用次数: " + Count;
  180. }
  181. OnPropertyChanged("Name");
  182. }
  183. }
  184. public string Name_NoWrite
  185. {
  186. get
  187. {
  188. return name;
  189. }
  190. set
  191. {
  192. name = value;
  193. if (StringUtil.IsEmpty(Path))
  194. {
  195. content = Name + "\n使用次数: " + Count;
  196. }
  197. else
  198. {
  199. content = Path + "\n" + Name + "\n使用次数: " + Count;
  200. }
  201. }
  202. }
  203. public string Path
  204. {
  205. get
  206. {
  207. return path;
  208. }
  209. set
  210. {
  211. path = value;
  212. if (StringUtil.IsEmpty(Path))
  213. {
  214. Content = Name + "\n使用次数: " + Count;
  215. }
  216. else
  217. {
  218. Content = Path + "\n" + Name + "\n使用次数: " + Count;
  219. }
  220. OnPropertyChanged("Path");
  221. }
  222. }
  223. public string Path_NoWrite
  224. {
  225. get
  226. {
  227. return path;
  228. }
  229. set
  230. {
  231. path = value;
  232. if (StringUtil.IsEmpty(Path))
  233. {
  234. content = Name + "\n使用次数: " + Count;
  235. }
  236. else
  237. {
  238. content = Path + "\n" + Name + "\n使用次数: " + Count;
  239. }
  240. }
  241. }
  242. public BitmapImage BitmapImage
  243. {
  244. get
  245. {
  246. return ImageUtil.ByteArrToImage(ImageByteArr);
  247. }
  248. set
  249. {
  250. bitmapImage = value;
  251. ImageByteArr = ImageUtil.BitmapImageToByte(bitmapImage);
  252. OnPropertyChanged("BitmapImage");
  253. }
  254. }
  255. public BitmapImage BitmapImage_NoWrite
  256. {
  257. get
  258. {
  259. return ImageUtil.ByteArrToImage(ImageByteArr_NoWrite);
  260. }
  261. set
  262. {
  263. bitmapImage = value;
  264. ImageByteArr_NoWrite = ImageUtil.BitmapImageToByte(bitmapImage);
  265. }
  266. }
  267. public byte[] ImageByteArr
  268. {
  269. get
  270. {
  271. return imageByteArr;
  272. }
  273. set
  274. {
  275. imageByteArr = value;
  276. OnPropertyChanged("ImageByteArr");
  277. }
  278. }
  279. public byte[] ImageByteArr_NoWrite
  280. {
  281. get
  282. {
  283. return imageByteArr;
  284. }
  285. set
  286. {
  287. imageByteArr = value;
  288. }
  289. }
  290. public string Content
  291. {
  292. get
  293. {
  294. return content;
  295. }
  296. set
  297. {
  298. content = value;
  299. OnPropertyChanged("Content");
  300. }
  301. }
  302. public string Content_NoWrite
  303. {
  304. get
  305. {
  306. return content;
  307. }
  308. set
  309. {
  310. content = value;
  311. }
  312. }
  313. [field: NonSerializedAttribute()]
  314. public event PropertyChangedEventHandler PropertyChanged;
  315. private void OnPropertyChanged(string propertyName)
  316. {
  317. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  318. CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
  319. }
  320. }
  321. }