/// <summary> /// Converts from the specified value to the intended conversion type of the converter. /// </summary> /// <param name="context">An object that provides a format context.</param> /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> to use as the current culture.</param> /// <param name="value">The value to convert to the type of this converter.</param> /// <returns> /// The converted value. /// </returns> public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { List <string> result = ((string)value).Split(',').ToList(); for (int j = 0; j < result.Count; j++) { var point = result[j]; if (string.IsNullOrEmpty(point)) { result[j] = "0"; } } if (result.Count % 2 != 0) { result.Add("0"); } PointsCollection collection = new PointsCollection(); for (int i = 0; i < result.Count; i += 2) { collection.Add(new ChartPoint() { XValue = double.Parse(result[i].ToString(CultureInfo.InvariantCulture)), YValue = double.Parse(result[i + 1].ToString(CultureInfo.InvariantCulture)) }); } return(collection); }
/// <summary> /// Gets the points from values. /// </summary> /// <param name="xValues">The x values.</param> /// <param name="yValues">The y values.</param> /// <returns></returns> protected PointsCollection GetPointsFromValues(List <double> xValues, List <double> yValues) { PointsCollection tempPoints = new PointsCollection(); for (int i = 0; (i < xValues.Count && i < yValues.Count); i++) { ChartPoint point = new ChartPoint() { XValue = xValues[i], YValue = yValues[i] }; tempPoints.Add(point); } return(tempPoints); }