/// <summary> /// Converts the specified format entity to a enumeration. /// </summary> public static EnumFormat Parse(Format format) { if (format == null) { throw new ArgumentNullException(nameof(format)); } EnumFormat enumFormat = Parse(format.Frmt); enumFormat.FormatID = format.FormatID; return(enumFormat); }
/// <summary> /// Converts the specified string to a enumeration. /// </summary> public static EnumFormat Parse(string s) { if (string.IsNullOrEmpty(s)) { return(new EnumFormat(0)); } else { string[] parts = s.Split(EnumSeparator); int valueCount = parts.Length; EnumFormat enumFormat = new EnumFormat(valueCount); for (int i = 0; i < valueCount; i++) { string part = parts[i]; int colonIdx = part.IndexOf(':'); string value = colonIdx < 0 ? part.Trim() : part.Substring(0, colonIdx).Trim(); string color = colonIdx < 0 ? "" : part.Substring(colonIdx + 1).Trim(); enumFormat.Values[i] = value; if (color != "") { enumFormat.Colors[i] = color; } else if (i == 0) { enumFormat.Colors[i] = EnumOffColor; } else if (i == 1) { enumFormat.Colors[i] = EnumOnColor; } else { enumFormat.Colors[i] = ""; } } return(enumFormat); } }