给应用添加图标,完成给设备添加变量表的功能
This commit is contained in:
@@ -7,6 +7,24 @@ namespace PMSWPF.Helper;
|
||||
|
||||
public class DataServicesHelper
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 从设备列表中找到变量表VarTable对象
|
||||
/// </summary>
|
||||
/// <param name="vtableId">VarTable的ID</param>
|
||||
/// <returns>如果找到择返回对象,否则返回null</returns>
|
||||
public static VariableTable FindVarTableForDevice(List<Device> devices, int vtableId)
|
||||
{
|
||||
VariableTable varTable = null;
|
||||
foreach (var device in devices)
|
||||
{
|
||||
varTable = device.VariableTables.FirstOrDefault(v => v.Id == vtableId);
|
||||
if (varTable != null)
|
||||
return varTable;
|
||||
}
|
||||
|
||||
return varTable;
|
||||
}
|
||||
public static MenuBean FindMenusForDevice(Device device,List<MenuBean> menus)
|
||||
{
|
||||
foreach (var mainMenu in menus)
|
||||
@@ -24,6 +42,23 @@ public class DataServicesHelper
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 给菜单排序
|
||||
/// </summary>
|
||||
/// <param name="menu"></param>
|
||||
public static void SortMenus(MenuBean menu)
|
||||
{
|
||||
if (menu.Items == null || menu.Items.Count() == 0)
|
||||
return;
|
||||
menu.Items.Sort((a, b) =>
|
||||
a.Type.ToString().Length.CompareTo(b.Type.ToString().Length)
|
||||
);
|
||||
foreach (var menuItem in menu.Items)
|
||||
{
|
||||
SortMenus(menuItem);
|
||||
}
|
||||
}
|
||||
|
||||
public static ViewModelBase GetMainViewModel(string name)
|
||||
{
|
||||
ViewModelBase navgateVM = App.Current.Services.GetRequiredService<HomeViewModel>();
|
||||
|
||||
Reference in New Issue
Block a user