/// <summary> /// Returns the information about specified resolution /// </summary> /// <param name="value">Chart resolution</param> /// <returns> /// A <see cref="ResolutionInformation"/> instance that contains the information about specified resolution. /// </returns> public static ResolutionInformation GetInformationFrom(KnownChartResolution value) { SentinelHelper.IsEnumValid(value); var type = value.GetType(); var field = type.GetField(value.ToString()); if (field == null) { return(null); } var attr = GetCustomAttribute(field, typeof(ScreenResolutionAttribute)) as ScreenResolutionAttribute; if (attr != null) { return(new ResolutionInformation { Size = attr.Size, Name = attr.Name, Width = attr.Width, Resolution = value, Height = attr.Height, AspectRatio = attr.AspectRatio, AspectRatioNormalized = attr.AspectRatioNormalized, AspectRatioValue = attr.AspectRatioValue }); } return(null); }
/// <summary> /// Returns the value of attribute of type <see cref="ScreenResolutionAttribute"/> for this enum value. /// If this attribute is not defined returns <b>null</b> (<b>Nothing</b> in Visual Basic) /// </summary> /// <param name="value">Target enum value.</param> /// <returns> /// A <see cref="ResolutionInformation"/> that contains the value of attribute. /// </returns> public static ResolutionInformation GetResolutionInformation(this KnownChartResolution value) { SentinelHelper.IsEnumValid(value); var type = value.GetType(); var field = type.GetField(value.ToString()); if (field == null) { return(null); } var attr = Attribute.GetCustomAttribute(field, typeof(ScreenResolutionAttribute)) as ScreenResolutionAttribute; return(attr != null ? ScreenResolutionAttribute.GetInformationFrom(value) : null); }