Sic.Framework/MECF.Framework.Common/MECF/Framework/Common/Account/Extends/AppMenu.cs

145 lines
2.8 KiB
C#
Raw Normal View History

2023-04-13 11:51:03 +08:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
namespace MECF.Framework.Common.Account.Extends
{
/// <summary>
///
/// </summary>
2023-04-13 11:51:03 +08:00
[Serializable]
public class AppMenu : INotifyPropertyChanged
{
#region Variables
2023-04-13 11:51:03 +08:00
private string _mStrMenuId;
private string _mStrViewModel;
private string _mStrResKey;
private string _system;
private int _permission;
private AppMenu _parent;
private List<AppMenu> _menuItems;
private bool _selected;
private bool _isAlarm;
private string _alarmModule;
2023-04-13 11:51:03 +08:00
#endregion
2023-04-13 11:51:03 +08:00
public string MenuID
2023-04-13 11:51:03 +08:00
{
get => _mStrMenuId;
set => _mStrMenuId = value;
}
2023-04-13 11:51:03 +08:00
public string ResKey
{
get => _mStrResKey;
set => _mStrResKey = value;
}
2023-04-13 11:51:03 +08:00
public List<AppMenu> MenuItems
{
get => _menuItems;
set => _menuItems = value;
}
2023-04-13 11:51:03 +08:00
public string ViewModel
{
get => _mStrViewModel;
set => _mStrViewModel = 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
public AppMenu Parent
{
get => _parent;
set => _parent = value;
}
2023-04-13 11:51:03 +08:00
public bool Selected
{
get => _selected;
set
2023-04-13 11:51:03 +08:00
{
_selected = value;
2023-04-13 11:51:03 +08:00
OnPropertyChanged("Selected");
}
}
public bool IsAlarm
{
get => _isAlarm;
set
2023-04-13 11:51:03 +08:00
{
_isAlarm = value;
OnPropertyChanged("IsAlarm");
}
}
public string AlarmModule
{
get => _alarmModule;
set => _alarmModule = value;
}
2023-04-13 11:51:03 +08:00
public object Model { get; set; }
public AppMenu LastSelectedSubMenu { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
public AppMenu()
{
}
public AppMenu(string p_strMenuID, string p_strMenuViewModel, string p_strResKey, List<AppMenu> p_menuItems)
{
_mStrMenuId = p_strMenuID;
_mStrViewModel = p_strMenuViewModel;
_mStrResKey = p_strResKey;
_menuItems = p_menuItems;
2023-04-13 11:51:03 +08:00
}
public object Clone(AppMenu parent)
{
AppMenu 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;
if (MenuItems != null)
{
appMenu.MenuItems = new List<AppMenu>();
foreach (AppMenu menuItem in MenuItems)
{
appMenu.MenuItems.Add((AppMenu)menuItem.Clone(appMenu));
}
}
return appMenu;
}
protected virtual void OnPropertyChanged(string propertyName)
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}