IconInfo.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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. }
  194. }
  195. public string Path
  196. {
  197. get
  198. {
  199. return path;
  200. }
  201. set
  202. {
  203. path = value;
  204. if (StringUtil.IsEmpty(Path))
  205. {
  206. Content = Name + "\n使用次数: " + Count;
  207. }
  208. else
  209. {
  210. Content = Path + "\n" + Name + "\n使用次数: " + Count;
  211. }
  212. OnPropertyChanged("Path");
  213. }
  214. }
  215. public string Path_NoWrite
  216. {
  217. get
  218. {
  219. return path;
  220. }
  221. set
  222. {
  223. path = value;
  224. }
  225. }
  226. public BitmapImage BitmapImage
  227. {
  228. get
  229. {
  230. return ImageUtil.ByteArrToImage(ImageByteArr);
  231. }
  232. set
  233. {
  234. bitmapImage = value;
  235. ImageByteArr = ImageUtil.BitmapImageToByte(bitmapImage);
  236. OnPropertyChanged("BitmapImage");
  237. }
  238. }
  239. public BitmapImage BitmapImage_NoWrite
  240. {
  241. get
  242. {
  243. return ImageUtil.ByteArrToImage(ImageByteArr_NoWrite);
  244. }
  245. set
  246. {
  247. bitmapImage = value;
  248. ImageByteArr_NoWrite = ImageUtil.BitmapImageToByte(bitmapImage);
  249. }
  250. }
  251. public byte[] ImageByteArr
  252. {
  253. get
  254. {
  255. return imageByteArr;
  256. }
  257. set
  258. {
  259. imageByteArr = value;
  260. OnPropertyChanged("ImageByteArr");
  261. }
  262. }
  263. public byte[] ImageByteArr_NoWrite
  264. {
  265. get
  266. {
  267. return imageByteArr;
  268. }
  269. set
  270. {
  271. imageByteArr = value;
  272. }
  273. }
  274. public string Content
  275. {
  276. get
  277. {
  278. return content;
  279. }
  280. set
  281. {
  282. content = value;
  283. OnPropertyChanged("Content");
  284. }
  285. }
  286. public string Content_NoWrite
  287. {
  288. get
  289. {
  290. return content;
  291. }
  292. set
  293. {
  294. content = value;
  295. }
  296. }
  297. [field: NonSerializedAttribute()]
  298. public event PropertyChangedEventHandler PropertyChanged;
  299. private void OnPropertyChanged(string propertyName)
  300. {
  301. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  302. CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
  303. }
  304. }
  305. }