MenuManager.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using MECF.Framework.Common.Account.Extends;
  7. namespace OpenSEMI.ClientBase
  8. {
  9. public class MenuManager
  10. {
  11. public List<AppMenu> MenuItems { get; private set; }
  12. #region Operation
  13. public void LoadMenu(List<AppMenu> menuitems)
  14. {
  15. foreach (AppMenu menuitem in menuitems)
  16. {
  17. if (menuitem.MenuItems != null)
  18. {
  19. for (int i = menuitem.MenuItems.Count - 1; i >= 0; i--)
  20. {
  21. var submenuitem = menuitem.MenuItems[i];
  22. submenuitem.Parent = menuitem;
  23. if (submenuitem.Permission == 1) //remove menu if permission is "None"
  24. menuitem.MenuItems.Remove(submenuitem);
  25. }
  26. }
  27. }
  28. this.MenuItems = menuitems;
  29. }
  30. public void FilterMenus(List<string> pSystems)
  31. {
  32. if (pSystems == null || this.MenuItems == null)
  33. return;
  34. foreach (AppMenu menuitem in this.MenuItems)
  35. {
  36. if (menuitem.MenuItems != null)
  37. {
  38. for (int i = menuitem.MenuItems.Count - 1; i >= 0; i--)
  39. {
  40. var submenuitem = menuitem.MenuItems[i];
  41. //filter
  42. }
  43. }
  44. }
  45. }
  46. private bool IsExist(List<string> pSource, string pMatch)
  47. {
  48. foreach (var item in pSource)
  49. {
  50. if (pMatch.IndexOf(item) >= 0)
  51. return true;
  52. }
  53. return false;
  54. }
  55. public List<AppMenu> GetAllClone()
  56. {
  57. if (this.MenuItems == null)
  58. return null;
  59. List<AppMenu> cloneList = new List<AppMenu>();
  60. foreach (var item in this.MenuItems)
  61. {
  62. cloneList.Add((AppMenu)item.Clone(item.Parent));
  63. }
  64. return cloneList;
  65. }
  66. #endregion
  67. }
  68. }