public void Init() { this.ImageList = images; this.CheckBoxes = true; this.Nodes.Clear(); TreeNode root = new TreeNode(RootText, 0, 0); this.Nodes.Add(root); List <TreeNode> catalogs = new List <TreeNode>(); Type operatorEnum = typeof(Permission); FieldInfo[] fields = operatorEnum.GetFields(); foreach (FieldInfo field in fields) { if (field.FieldType.IsEnum) { object[] attrs = field.GetCustomAttributes(false); foreach (object attr in attrs) { if (attr is OperatorRightAttribute) { OperatorRightAttribute right = attr as OperatorRightAttribute; Permission permission = (Permission)field.GetValue(null); string catalog = right.Catalog; // LJH.Attendance.Model.PermissionDescription.GetDescription(right.Catalog); TreeNode catalogNode = catalogs.Find(t => t.Text == catalog); if (catalogNode == null) { catalogNode = new TreeNode(catalog, 0, 0); root.Nodes.Add(catalogNode); catalogs.Add(catalogNode); } string temp = right.Description;// LJH.Attendance.Model.PermissionDescription.GetDescription(permission); TreeNode rightNode = new TreeNode(temp, 1, 1); rightNode.Tag = permission; catalogNode.Nodes.Add(rightNode); _rightNodes.Add(rightNode); } } } } root.Expand(); this.AfterCheck += Node_Checked; }
public void Init() { this.ImageList = images; this.CheckBoxes = true; this.Nodes.Clear(); TreeNode root = new TreeNode(RootText, 0, 0); this.Nodes.Add(root); List <TreeNode> catalogs = new List <TreeNode>(); Type operatorEnum = typeof(PREPermission); FieldInfo[] fields = operatorEnum.GetFields(); foreach (FieldInfo field in fields) { if (field.FieldType.IsEnum) { object[] attrs = field.GetCustomAttributes(false); foreach (object attr in attrs) { if (attr is OperatorRightAttribute) { OperatorRightAttribute right = attr as OperatorRightAttribute; PREPermission permission = (PREPermission)field.GetValue(null); //if (GlobalVariables.IsNETParkAndOffLie) //{ // //写卡模式,不显示的权限 // if (permission == Permission.RemoteReadCard) // { // continue; // } //} //else //{ // //其他模式,不显示的权限 // if (permission == Permission.DownloadAllCards) // { // continue; // } //} string catalog = Ralid.Park.BusinessModel.Resouce.PermissionDescription.GetPREDescription(right.Catalog); TreeNode catalogNode = catalogs.Find(t => t.Text == catalog); if (catalogNode == null) { catalogNode = new TreeNode(catalog, 0, 0); root.Nodes.Add(catalogNode); catalogs.Add(catalogNode); } string temp = Ralid.Park.BusinessModel.Resouce.PermissionDescription.GetDescription(permission); TreeNode rightNode = new TreeNode(temp, 1, 1); rightNode.Tag = permission; catalogNode.Nodes.Add(rightNode); _rightNodes.Add(rightNode); } } } } root.Expand(); this.AfterCheck += Node_Checked; }