Пример #1
0
 /// <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
         });
         TotalYValues = YValues.Sum();
     }
     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);
         TotalYValues = YValues.Sum();
     }
     else if (e.Action == NotifyCollectionChangedAction.Reset)
     {
         Points.Clear();
         GeneratePointsFromSource();
     }
 }