public static string GetDescription(EnumNotifyType en) { Type type = en.GetType(); //获取类型 MemberInfo[] memberInfos = type.GetMember(en.ToString()); //获取成员 if (memberInfos != null && memberInfos.Length > 0) { DescriptionAttribute[] attrs = memberInfos[0].GetCustomAttributes(typeof(DescriptionAttribute), false) as DescriptionAttribute[]; //获取描述特性 if (attrs != null && attrs.Length > 0) { return(attrs[0].Description); //返回当前描述 } } return(en.ToString()); }
private void SetForeground(EnumNotifyType type) { string key = type.ToString() + "Foreground_Colors"; if (!_Brushes.ContainsKey(key)) { var b = this.TryFindResource(key) as Brush; _Brushes.Add(key, b); } this.Foreground = _Brushes[key]; }