using Model; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Permission { public static class PermissionHelper { private static readonly Dictionary _permissionLevels = new Dictionary(); public static void SetPermissionLevel(this Control control, PermissionLevel level) { if (control == null) return; _permissionLevels[control] = level; } public static PermissionLevel GetPermissionLevel(this Control control) { return control != null && _permissionLevels.TryGetValue(control, out PermissionLevel level) ? level : PermissionLevel.无权限; } } }