1
0

IconInfo.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. using GeekDesk.Constant;
  2. using GeekDesk.Util;
  3. using System;
  4. using System.ComponentModel;
  5. using System.IO;
  6. using System.Windows.Media.Imaging;
  7. /// <summary>
  8. /// 图标信息
  9. /// </summary>
  10. namespace GeekDesk.ViewModel
  11. {
  12. [Serializable]
  13. public class IconInfo : INotifyPropertyChanged
  14. {
  15. private string path; //路径
  16. private string name; //文件名
  17. private int count = 0; //打开次数
  18. [field: NonSerialized]
  19. private BitmapImage bitmapImage; //位图
  20. private byte[] imageByteArr; //图片 byte数组
  21. private string content; //显示信息
  22. private int imageWidth = (int)CommonEnum.IMAGE_WIDTH; //图片宽度
  23. private int imageHeight = (int)CommonEnum.IMAGE_HEIGHT; //图片高度
  24. private bool adminStartUp = false; //始终管理员方式启动 默认否
  25. private byte[] defaultImage; //默认图标
  26. private IconType iconType = IconType.OTHER;
  27. public IconType IconType
  28. {
  29. get
  30. {
  31. if (iconType == 0) return IconType.OTHER;
  32. return iconType;
  33. }
  34. set
  35. {
  36. iconType = value;
  37. OnPropertyChanged("IconType");
  38. }
  39. }
  40. public byte[] DefaultImage
  41. {
  42. get
  43. {
  44. return defaultImage;
  45. }
  46. set
  47. {
  48. defaultImage = value;
  49. OnPropertyChanged("DefaultImage");
  50. }
  51. }
  52. public bool AdminStartUp
  53. {
  54. get
  55. {
  56. return adminStartUp;
  57. }
  58. set
  59. {
  60. adminStartUp = value;
  61. OnPropertyChanged("AdminStartUp");
  62. }
  63. }
  64. public int Count
  65. {
  66. get
  67. {
  68. return count;
  69. }
  70. set
  71. {
  72. count = value;
  73. Content = Path + "\n" + Name + "\n使用次数: " + Count;
  74. OnPropertyChanged("Count");
  75. }
  76. }
  77. public string Name
  78. {
  79. get
  80. {
  81. return name;
  82. }
  83. set
  84. {
  85. name = value;
  86. Content = Path + "\n" + Name + "\n使用次数: " + Count;
  87. OnPropertyChanged("Name");
  88. }
  89. }
  90. public string Path
  91. {
  92. get
  93. {
  94. return path;
  95. }
  96. set
  97. {
  98. path = value;
  99. Content = Path + "\n" + Name + "\n使用次数: " + Count;
  100. OnPropertyChanged("Path");
  101. }
  102. }
  103. public BitmapImage BitmapImage
  104. {
  105. get
  106. {
  107. return ImageUtil.ByteArrToImage(ImageByteArr);
  108. }
  109. set
  110. {
  111. bitmapImage = value;
  112. ImageByteArr = ImageUtil.BitmapImageToByte(bitmapImage);
  113. OnPropertyChanged("BitmapImage");
  114. }
  115. }
  116. public byte[] ImageByteArr
  117. {
  118. get
  119. {
  120. return imageByteArr;
  121. }
  122. set
  123. {
  124. imageByteArr = value;
  125. OnPropertyChanged("ImageByteArr");
  126. }
  127. }
  128. public string Content
  129. {
  130. get
  131. {
  132. return content;
  133. }
  134. set
  135. {
  136. content = value;
  137. OnPropertyChanged("Content");
  138. }
  139. }
  140. public int ImageWidth
  141. {
  142. get
  143. {
  144. // 为了兼容旧版 暂时使用默认
  145. return (int)CommonEnum.IMAGE_WIDTH;
  146. }
  147. set
  148. {
  149. imageWidth = value;
  150. OnPropertyChanged("ImageWidth");
  151. }
  152. }
  153. public int ImageHeight
  154. {
  155. get
  156. {
  157. // 为了兼容旧版 暂时使用默认
  158. return (int)CommonEnum.IMAGE_HEIGHT;
  159. }
  160. set
  161. {
  162. imageHeight = value;
  163. OnPropertyChanged("ImageHeight");
  164. }
  165. }
  166. [field: NonSerializedAttribute()]
  167. public event PropertyChangedEventHandler PropertyChanged;
  168. private void OnPropertyChanged(string propertyName)
  169. {
  170. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  171. CommonCode.SaveAppData(MainWindow.appData);
  172. }
  173. }
  174. }