IconInfo.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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)MainWindowEnum.IMAGE_WIDTH; //图片宽度
  23. private int imageHeight = (int)MainWindowEnum.IMAGE_HEIGHT; //图片高度
  24. private bool adminStartUp = false; //始终管理员方式启动 默认否
  25. private byte[] defaultImage; //默认图标
  26. public byte[] DefaultImage
  27. {
  28. get
  29. {
  30. return defaultImage;
  31. }
  32. set
  33. {
  34. defaultImage = value;
  35. OnPropertyChanged("DefaultImage");
  36. }
  37. }
  38. public bool AdminStartUp
  39. {
  40. get
  41. {
  42. return adminStartUp;
  43. }
  44. set
  45. {
  46. adminStartUp = value;
  47. OnPropertyChanged("AdminStartUp");
  48. }
  49. }
  50. public int Count
  51. {
  52. get
  53. {
  54. return count;
  55. }
  56. set
  57. {
  58. count = value;
  59. Content = Path + "\n" + Name + "\n使用次数: " + Count;
  60. OnPropertyChanged("Count");
  61. }
  62. }
  63. public string Name
  64. {
  65. get
  66. {
  67. return name;
  68. }
  69. set
  70. {
  71. name = value;
  72. Content = Path + "\n" + Name + "\n使用次数: " + Count;
  73. OnPropertyChanged("Name");
  74. }
  75. }
  76. public string Path
  77. {
  78. get
  79. {
  80. return path;
  81. }
  82. set
  83. {
  84. path = value;
  85. Content = Path + "\n" + Name + "\n使用次数: " + Count;
  86. OnPropertyChanged("Path");
  87. }
  88. }
  89. public BitmapImage BitmapImage
  90. {
  91. get
  92. {
  93. return ImageUtil.ByteArrToImage(ImageByteArr);
  94. }
  95. set
  96. {
  97. bitmapImage = value;
  98. ImageByteArr = ImageUtil.BitmapImageToByte(bitmapImage);
  99. OnPropertyChanged("BitmapImage");
  100. }
  101. }
  102. public byte[] ImageByteArr
  103. {
  104. get
  105. {
  106. return imageByteArr;
  107. }
  108. set
  109. {
  110. imageByteArr = value;
  111. OnPropertyChanged("ImageByteArr");
  112. }
  113. }
  114. public string Content
  115. {
  116. get
  117. {
  118. return content;
  119. }
  120. set
  121. {
  122. content = value;
  123. OnPropertyChanged("Content");
  124. }
  125. }
  126. public int ImageWidth
  127. {
  128. get
  129. {
  130. return imageWidth;
  131. }
  132. set
  133. {
  134. imageWidth = value;
  135. OnPropertyChanged("ImageWidth");
  136. }
  137. }
  138. public int ImageHeight
  139. {
  140. get
  141. {
  142. return imageHeight;
  143. }
  144. set
  145. {
  146. imageHeight = value;
  147. OnPropertyChanged("ImageHeight");
  148. }
  149. }
  150. [field: NonSerializedAttribute()]
  151. public event PropertyChangedEventHandler PropertyChanged;
  152. private void OnPropertyChanged(string propertyName)
  153. {
  154. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  155. CommonCode.SaveAppData(MainWindow.appData);
  156. }
  157. }
  158. }