终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

93 line
2.9 KiB

  1. using BPASmart.VariableManager.Models;
  2. using BPASmartClient.CustomResource.Pages.Enums;
  3. using BPASmartClient.CustomResource.Pages.Model;
  4. using BPASmartClient.CustomResource.Pages.View;
  5. using BPASmartClient.Helper;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Collections.ObjectModel;
  9. using System.Configuration;
  10. using System.Data;
  11. using System.Linq;
  12. using System.Threading.Tasks;
  13. using System.Windows;
  14. namespace BPASmart.VariableManager
  15. {
  16. /// <summary>
  17. /// Interaction logic for App.xaml
  18. /// </summary>
  19. public partial class App : Application
  20. {
  21. public static Window MainWindow;
  22. protected override void OnStartup(StartupEventArgs e)
  23. {
  24. base.OnStartup(e);
  25. MenuInit();
  26. MainView mv = new MainView();
  27. mv.WindowState = WindowState.Normal;
  28. MainWindow = mv;
  29. mv.Show();
  30. }
  31. private void MenuInit()
  32. {
  33. Json<CommunicationPar>.Read();
  34. #region 设备管理
  35. ObservableCollection<SubMenumodel> DeviceMonitor = new ObservableCollection<SubMenumodel>();
  36. DeviceMonitor.Add(new SubMenumodel()
  37. {
  38. SubMenuName = "设备管理",
  39. AssemblyName = "BPASmart.VariableManager",
  40. ToggleWindowPath = "Views.CommunicationSetView",
  41. SubMenuVisibility = Visibility.Visible,
  42. });
  43. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  44. {
  45. MainMenuIcon = "&#xe603;",
  46. MainMenuName = "设备管理",
  47. Alias = "Device Management",
  48. subMenumodels = DeviceMonitor,
  49. });
  50. #endregion
  51. #region 变量管理,根据创建的通讯设备自动生成子菜单
  52. ObservableCollection<SubMenumodel> RecipeManage = new ObservableCollection<SubMenumodel>();
  53. ActionManage.GetInstance.Register(new Action<object>((o) =>
  54. {
  55. RecipeManage.Add(AddSubMenuModel(o.ToString()));
  56. }), "AddCommunicationDevice");
  57. Json<CommunicationPar>.Data.CommunicationDevices?.ToList()?.ForEach(item =>
  58. {
  59. RecipeManage.Add(AddSubMenuModel(item.DeviceName));
  60. });
  61. MenuManage.GetInstance.menuModels.Add(new MenuModel()
  62. {
  63. MainMenuIcon = "&#xe62d;",
  64. MainMenuName = "变量管理",
  65. Alias = "Recipe Management",
  66. subMenumodels = RecipeManage,
  67. });
  68. #endregion
  69. }
  70. private SubMenumodel AddSubMenuModel(string s)
  71. {
  72. return new SubMenumodel()
  73. {
  74. SubMenuName = s,
  75. AssemblyName = "BPASmart.VariableManager",
  76. ToggleWindowPath = "Views.VariableConfig",
  77. SubMenuVisibility = Visibility.Visible,
  78. };
  79. }
  80. }
  81. }