MenuInfo.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. public bool IsEncrypt
  21. {
  22. get
  23. {
  24. return isEncrypt;
  25. }
  26. set
  27. {
  28. isEncrypt = value;
  29. OnPropertyChanged("IsEncrypt");
  30. }
  31. }
  32. public string MenuGeometry
  33. {
  34. get
  35. {
  36. if (menuGeometry == null)
  37. {
  38. return Constants.DEFAULT_MENU_GEOMETRY;
  39. }
  40. return menuGeometry;
  41. }
  42. set
  43. {
  44. menuGeometry = value;
  45. OnPropertyChanged("MenuGeometry");
  46. }
  47. }
  48. public string GeometryColor
  49. {
  50. get
  51. {
  52. if (geometryColor == null)
  53. {
  54. return Constants.DEFAULT_MENU_GEOMETRY_COLOR;
  55. }
  56. return geometryColor;
  57. }
  58. set
  59. {
  60. geometryColor = value;
  61. OnPropertyChanged("GeometryColor");
  62. }
  63. }
  64. public string MenuName
  65. {
  66. get
  67. {
  68. return menuName;
  69. }
  70. set
  71. {
  72. menuName = value;
  73. OnPropertyChanged("MenuName");
  74. }
  75. }
  76. public string MenuId
  77. {
  78. get
  79. {
  80. return menuId;
  81. }
  82. set
  83. {
  84. menuId = value;
  85. OnPropertyChanged("MenuId");
  86. }
  87. }
  88. public Visibility MenuEdit
  89. {
  90. get
  91. {
  92. return menuEdit;
  93. }
  94. set
  95. {
  96. menuEdit = value;
  97. if (menuEdit == Visibility.Visible)
  98. {
  99. NotMenuEdit = Visibility.Collapsed;
  100. }
  101. else
  102. {
  103. NotMenuEdit = Visibility.Visible;
  104. }
  105. OnPropertyChanged("MenuEdit");
  106. }
  107. }
  108. public Visibility NotMenuEdit
  109. {
  110. get
  111. {
  112. return notMenuEdit;
  113. }
  114. set
  115. {
  116. notMenuEdit = value;
  117. OnPropertyChanged("NotMenuEdit");
  118. }
  119. }
  120. public ObservableCollection<IconInfo> IconList
  121. {
  122. get
  123. {
  124. return iconList;
  125. }
  126. set
  127. {
  128. iconList = value;
  129. OnPropertyChanged("IconList");
  130. }
  131. }
  132. [field: NonSerializedAttribute()]
  133. public event PropertyChangedEventHandler PropertyChanged;
  134. private void OnPropertyChanged(string propertyName)
  135. {
  136. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  137. CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
  138. }
  139. }
  140. }