Sic.Framework-Nanjing-Baishi/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/AppMenu.cs

184 lines
3.5 KiB
C#
Raw Normal View History

2023-04-13 11:51:03 +08:00
using System;
using System.Collections.Generic;
using Sicentury.Core;
2023-04-13 11:51:03 +08:00
namespace MECF.Framework.Common.Account.Extends
{
/// <summary>
///
/// </summary>
2023-04-13 11:51:03 +08:00
[Serializable]
public class AppMenu : BindableBase
2023-04-13 11:51:03 +08:00
{
#region Variables
private string _menuID;
private string _menuViewModel;
private string _resKey;
private string _system;
private int _permission;
private AppMenu _parent;
private List<AppMenu> _subMenus;
private bool _selected;
private bool _isAlarm;
private string _alarmModule;
private string _description;
#endregion
#region Constructors
2023-04-13 11:51:03 +08:00
public AppMenu()
{
}
public AppMenu(string menuID, string menuViewModel, string resKey, List<AppMenu> subMenus, string description = "")
{
_menuID = menuID;
_menuViewModel = menuViewModel;
_resKey = resKey;
_subMenus = subMenus;
_description = description;
}
2023-04-13 11:51:03 +08:00
#endregion
2023-04-13 11:51:03 +08:00
#region Properties
2023-04-13 11:51:03 +08:00
public string MenuID
2023-04-13 11:51:03 +08:00
{
get => _menuID;
set => _menuID = value;
}
2023-04-13 11:51:03 +08:00
public string ResKey
2023-04-13 11:51:03 +08:00
{
get => _resKey;
set => _resKey = value;
}
2023-04-13 11:51:03 +08:00
public List<AppMenu> MenuItems
{
get => _subMenus;
set => _subMenus = value;
}
2023-04-13 11:51:03 +08:00
public string ViewModel
{
get => _menuViewModel;
set => _menuViewModel = value;
}
2023-04-13 11:51:03 +08:00
public int Permission
{
get => _permission;
set => _permission = value;
}
2023-04-13 11:51:03 +08:00
public string System
{
get => _system;
set => _system = value;
}
2023-04-13 11:51:03 +08:00
/// <summary>
/// 设置或返回当前菜单的父菜单。
/// </summary>
2023-04-13 11:51:03 +08:00
public AppMenu Parent
{
get => _parent;
set => _parent = value;
}
2023-04-13 11:51:03 +08:00
/// <summary>
/// 设置或返回当前菜单是否被选中。
/// </summary>
2023-04-13 11:51:03 +08:00
public bool Selected
{
get => _selected;
set => Set(ref _selected, value);
2023-04-13 11:51:03 +08:00
}
/// <summary>
/// 设置或返回是否在当前菜单是否有报警。
/// </summary>
2023-04-13 11:51:03 +08:00
public bool IsAlarm
{
get => _isAlarm;
set => Set(ref _isAlarm, value);
2023-04-13 11:51:03 +08:00
}
/// <summary>
/// 设置或返回报警模组。
/// </summary>
2023-04-13 11:51:03 +08:00
public string AlarmModule
{
get => _alarmModule;
set => Set(ref _alarmModule, value);
}
2023-04-13 11:51:03 +08:00
public object Model { get; set; }
/// <summary>
/// 设置或返回被选中的子菜单。
/// </summary>
2023-04-13 11:51:03 +08:00
public AppMenu LastSelectedSubMenu { get; set; }
/// <summary>
/// 返回当前菜单的描述。
/// </summary>
public string Description
2023-04-13 11:51:03 +08:00
{
get => _description;
set => _description = value;
2023-04-13 11:51:03 +08:00
}
#endregion
2023-04-13 11:51:03 +08:00
#region Methods
2023-04-13 11:51:03 +08:00
public object Clone(AppMenu parent)
{
var appMenu = new AppMenu();
2023-04-13 11:51:03 +08:00
appMenu.MenuID = MenuID;
appMenu.ResKey = ResKey;
appMenu.ViewModel = ViewModel;
appMenu.Permission = Permission;
appMenu.Selected = Selected;
appMenu.System = System;
appMenu.Parent = parent;
appMenu.IsAlarm = IsAlarm;
appMenu.AlarmModule = AlarmModule;
appMenu.Description = Description;
2023-04-13 11:51:03 +08:00
if (MenuItems != null)
{
appMenu.MenuItems = new List<AppMenu>();
foreach (var menuItem in MenuItems)
2023-04-13 11:51:03 +08:00
{
appMenu.MenuItems.Add((AppMenu)menuItem.Clone(appMenu));
}
}
2023-04-13 11:51:03 +08:00
return appMenu;
}
#endregion
/*public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
2023-04-13 11:51:03 +08:00
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
2023-04-13 11:51:03 +08:00
}
protected bool Set<T>(ref T field, T value, [CallerMemberName] string propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
field = value;
OnPropertyChanged(propertyName);
return true;
}*/
2023-04-13 11:51:03 +08:00
}
}