using Microsoft.Extensions.DependencyInjection; using PMSWPF.Enums; using PMSWPF.Models; using PMSWPF.ViewModels; namespace PMSWPF.Helper; public class DataServicesHelper { public static MenuBean FindMenusForDevice(Device device,List menus) { foreach (var mainMenu in menus) { if (mainMenu.Items == null || mainMenu.Items.Count == 0) continue; foreach (var secondMenu in mainMenu.Items) { if (secondMenu.Type == MenuType.DeviceMenu && secondMenu.Data != null && secondMenu.Data == device) { return secondMenu; } } } return null; } public static ViewModelBase GetMainViewModel(string name) { ViewModelBase navgateVM = App.Current.Services.GetRequiredService(); switch (name) { case "主页": navgateVM = App.Current.Services.GetRequiredService(); break; case "设备": navgateVM = App.Current.Services.GetRequiredService(); break; case "数据转换": navgateVM = App.Current.Services.GetRequiredService(); break; case "设置": navgateVM = App.Current.Services.GetRequiredService(); break; } return navgateVM; } }