MenuInfo.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. using GeekDesk.Constant;
  2. using GeekDesk.Util;
  3. using System;
  4. using System.Collections.ObjectModel;
  5. using System.ComponentModel;
  6. using System.Windows;
  7. namespace GeekDesk.ViewModel
  8. {
  9. [Serializable]
  10. public class MenuInfo : INotifyPropertyChanged
  11. {
  12. private string menuName;
  13. private string menuId;
  14. private Visibility menuEdit = Visibility.Collapsed;
  15. private Visibility notMenuEdit = Visibility.Visible;
  16. private string menuGeometry; //菜单几何图标
  17. private string geometryColor; //几何图标颜色
  18. private ObservableCollection<IconInfo> iconList = new ObservableCollection<IconInfo>();
  19. private bool isEncrypt; //是否加密
  20. private MenuType menuType; //菜单类型 普通, 关联
  21. private string linkPath; //关联路径
  22. public string LinkPath
  23. {
  24. get
  25. {
  26. return linkPath;
  27. }
  28. set
  29. {
  30. linkPath = value;
  31. OnPropertyChanged("LinkPath");
  32. }
  33. }
  34. public MenuType MenuType
  35. {
  36. get
  37. {
  38. return menuType;
  39. }
  40. set
  41. {
  42. menuType = value;
  43. OnPropertyChanged("MenuType");
  44. }
  45. }
  46. public bool IsEncrypt
  47. {
  48. get
  49. {
  50. return isEncrypt;
  51. }
  52. set
  53. {
  54. isEncrypt = value;
  55. OnPropertyChanged("IsEncrypt");
  56. }
  57. }
  58. public string MenuGeometry
  59. {
  60. get
  61. {
  62. if (menuGeometry == null)
  63. {
  64. return Constants.DEFAULT_MENU_GEOMETRY;
  65. }
  66. return menuGeometry;
  67. }
  68. set
  69. {
  70. menuGeometry = value;
  71. OnPropertyChanged("MenuGeometry");
  72. }
  73. }
  74. public string GeometryColor
  75. {
  76. get
  77. {
  78. if (geometryColor == null)
  79. {
  80. return Constants.DEFAULT_MENU_GEOMETRY_COLOR;
  81. }
  82. return geometryColor;
  83. }
  84. set
  85. {
  86. geometryColor = value;
  87. OnPropertyChanged("GeometryColor");
  88. }
  89. }
  90. public string MenuName
  91. {
  92. get
  93. {
  94. return menuName;
  95. }
  96. set
  97. {
  98. menuName = value;
  99. OnPropertyChanged("MenuName");
  100. }
  101. }
  102. public string MenuId
  103. {
  104. get
  105. {
  106. return menuId;
  107. }
  108. set
  109. {
  110. menuId = value;
  111. OnPropertyChanged("MenuId");
  112. }
  113. }
  114. public Visibility MenuEdit
  115. {
  116. get
  117. {
  118. return menuEdit;
  119. }
  120. set
  121. {
  122. menuEdit = value;
  123. if (menuEdit == Visibility.Visible)
  124. {
  125. NotMenuEdit = Visibility.Collapsed;
  126. }
  127. else
  128. {
  129. NotMenuEdit = Visibility.Visible;
  130. }
  131. OnPropertyChanged("MenuEdit");
  132. }
  133. }
  134. public Visibility NotMenuEdit
  135. {
  136. get
  137. {
  138. return notMenuEdit;
  139. }
  140. set
  141. {
  142. notMenuEdit = value;
  143. OnPropertyChanged("NotMenuEdit");
  144. }
  145. }
  146. public ObservableCollection<IconInfo> IconList
  147. {
  148. get
  149. {
  150. return iconList;
  151. }
  152. set
  153. {
  154. iconList = value;
  155. OnPropertyChanged("IconList");
  156. }
  157. }
  158. [field: NonSerializedAttribute()]
  159. public event PropertyChangedEventHandler PropertyChanged;
  160. private void OnPropertyChanged(string propertyName)
  161. {
  162. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  163. CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
  164. }
  165. }
  166. }