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