/// <summary> /// The update data. /// </summary> protected internal override void UpdateData() { if (this.ItemsSource == null) { return; } var points = this.Points; points.Clear(); // Use the mapping to generate the points if (this.Mapping != null) { foreach (var item in this.ItemsSource) { points.Add(this.Mapping(item)); } return; } // Get DataPoints from the items in ItemsSource // if they implement IScatterPointProvider // If DataFields are set, this is not used /*if (DataFieldX == null || DataFieldY == null) * { * foreach (var item in ItemsSource) * { * var idpp = item as IScatterPointProvider; * if (idpp == null) * { * continue; * } * * points.Add(idpp.GetScatterPoint()); * } * * return; * }*/ var dest = new List <IDataPoint>(); // Using reflection to add points var filler = new ListFiller <ScatterPoint>(); filler.Add(this.DataFieldX, (item, value) => item.X = Convert.ToDouble(value)); filler.Add(this.DataFieldY, (item, value) => item.Y = Convert.ToDouble(value)); filler.Add(this.DataFieldSize, (item, value) => item.Size = Convert.ToDouble(value)); filler.Add(this.DataFieldValue, (item, value) => item.Value = Convert.ToDouble(value)); filler.Add(this.DataFieldTag, (item, value) => item.Tag = value); filler.Fill(dest, this.ItemsSource); this.Points = dest; }
/// <summary> /// Updates the data. /// </summary> protected internal override void UpdateData() { if (this.ItemsSource == null) { return; } var dest = new List <T>(); // Using reflection to add points var filler = new ListFiller <T>(); filler.Add(this.ValueField, (item, value) => item.Value = Convert.ToDouble(value)); filler.Add(this.ColorField, (item, value) => item.Color = (OxyColor)value); filler.Fill(dest, this.ItemsSource); this.Items = dest; }