IconInfo.cs 6.8 KB

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