/// <summary> /// Handles the CollectionChanged event of the PointsSource control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="NotifyCollectionChangedEventArgs"/> instance containing the event data.</param> void PointsSource_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { double xValue = GetReflectionValue(XPath, PointsSource, XValues.Count + 1); double yValue = GetReflectionValue(YPath, PointsSource, YValues.Count + 1); XValues.Add(xValue); YValues.Add(xValue); Points.Add(new ChartPoint() { XValue = xValue, YValue = yValue }); } else if (e.Action == NotifyCollectionChangedAction.Remove) { IList oldItems = e.OldItems; double oldXValue = GetReflectionValueFromItem(XPath, oldItems[0]); int index = XValues.IndexOf(oldXValue); XValues.RemoveAt(index); YValues.RemoveAt(index); Points.RemoveAt(index); } else if (e.Action == NotifyCollectionChangedAction.Reset) { Points.Clear(); GeneratePointsFromSource(); } }
public void addData(double x, double y, double z) { lock (_lockObj) { XValues.Add(new DataPoint(XValues.Count, x)); YValues.Add(new DataPoint(YValues.Count, y)); ZValues.Add(new DataPoint(ZValues.Count, z)); if (MaxCount == ZValues.Count) { XValues.RemoveAt(0); reNumbering(XValues); YValues.RemoveAt(0); reNumbering(YValues); ZValues.RemoveAt(0); reNumbering(ZValues); } parseData(); } }