//Convert Meta.OutputInfo to string and vice versa public static Meta.OutputInfo[] String2OutputInfo(string str) { Meta.OutputInfo[] outputInfoList = new Meta.OutputInfo[0]; string[] items = common.system.String2List(str); for (int idx = 0; idx < items.Length; idx++) { string[] parts = common.system.String2List(items[idx], ":"); Color color = Data.sysDefaultLineColor; if (parts.Length > 0) { color = ColorTranslator.FromHtml(parts[0]); } int weight = 1; if (parts.Length > 1) { int.TryParse(parts[1], out weight); } AppTypes.ChartTypes chartType = AppTypes.ChartTypes.Line; if (parts.Length > 2) { chartType = AppTypes.Text2ChartType(parts[2]); } Array.Resize(ref outputInfoList, outputInfoList.Length + 1); outputInfoList[outputInfoList.Length - 1] = new Meta.OutputInfo(color, weight, chartType); } return(outputInfoList); }
/// <summary> /// Set Output property from a formated string. /// </summary> /// <param name="str"> In the format ([key]=[Color]:[Weight*]:[ChartType*]) </param> /// <returns></returns> private static common.DictionaryList String2OutputList(string str) { common.DictionaryList list = new common.DictionaryList(); common.myKeyValueItem[] keyValues = common.system.String2KeyValueList(str, ",", "="); Color color = Data.sysDefaultLineColor; int weight = 1; AppTypes.ChartTypes chartType = Data.sysDefaultLineChartType; for (int idx = 0; idx < keyValues.Length; idx++) { string[] parts = common.system.String2List(keyValues[idx].Value, ":", StringSplitOptions.None); color = (parts.Length > 0 ? ColorTranslator.FromHtml(parts[0]) : Data.sysDefaultLineColor); weight = Data.sysDefaultLineWeight; if (parts.Length > 1) { int.TryParse(parts[1], out weight); } chartType = (parts.Length > 2 ? AppTypes.Text2ChartType(parts[2]) : Data.sysDefaultLineChartType); list.Add(keyValues[idx].Key, new Meta.OutputInfo(color, weight, chartType)); } return(list); }