/// <summary> /// Gets data from a series using the Points collection. /// </summary> /// <param name="s">reference to a series object</param> /// <param name="g_data">reference to a GraphDataForm object</param> /// <param name="hastime">specify whether series has time axis</param> private void GetDataPoints(Series s, GraphDataForm g_data, bool hastime) { string time = null; //iterate through all points in series //If the collection is empty, use an iterator foreach (SeriesPoint point in s) { if (hastime) { //decode time to hh:mm:ss time = DecodeTime(point.RelativeTime); } else { //series doesn't have a time axis time = point.RelativeTime.ToString(); } //create an array of points string[] columns = new string[point.Values.Count]; for (int i = 0; i < point.Values.Count; i++) { columns[i] = point.Values[i].Value.ToString("0.00000000");//all points are calculated with 8 digits precision } //assign created array to ListView g_data.ListBeginUpdate(); g_data.FillFirstColumn(time).SubItems.AddRange(columns); g_data.ListEndUpdate(); } /* Use the following code if you need to fire a SeriesLoadPoints event * * string time = null; * * for (int i = 0; i < s.Points.Count; i++) * { * if (hastime) * { * //decode time to hh:mm:ss * time = DecodeTime(point.RelativeTime); * } * else * { * //series doesn't have a time axis * time = s.Points[i].RelativeTime.ToString(); * } * * //create an array with all points * string[] columns = new string[s.Points[i].Values.Count]; * for (int y = 0; y < s.Points[i].Values.Count; y++) * columns[y] = s.Points[i].Values[y].Value.ToString("0.00000000"); * * //assign created array to ListView * g_data.ListBeginUpdate(); * g_data.FillFirstColumn(time).SubItems.AddRange(columns); * g_data.ListEndUpdate(); * } * */ }
/// <summary> /// Gets data from a series using an iterator. /// </summary> /// <param name="s">reference to a series object</param> /// <param name="g_data">reference to a GraphDataForm object</param> /// <param name="hastime">specify whether series has time axis</param> private void GetDataWithIterator(Series s, GraphDataForm g_data, bool hastime) { //check if iterator can be used if (!s.CanUsePointsIterator()) { MessageBox.Show("Iterator cannot be used"); return; } //get iterator SeriesPointIterator pi = s.GetPointsIterator(); string time = null; //iterate through all points using iterator foreach (SeriesPoint pt in pi) { if (hastime) { //decode time to hh:mm:ss time = DecodeTime(pt.RelativeTime); } else { //series doesn't have a time axis time = pt.RelativeTime.ToString(); } //create an array with all points string[] columns = new string[pt.Values.Count]; for (int i = 0; i < pt.Values.Count; i++) { columns[i] = pt.Values[i].Value.ToString("0.00000000"); } //assign created array to ListView g_data.ListBeginUpdate(); g_data.FillFirstColumn(time).SubItems.AddRange(columns); g_data.ListEndUpdate(); } }