MenuInfo.cs 3.3 KB

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