/// <summary>
        /// Updates the data.
        /// </summary>
        protected internal override void UpdateData()
        {
            if (this.ItemsSource == null)
            {
                return;
            }

            var sourceAsListOfT = this.ItemsSource as List <T>;

            if (sourceAsListOfT != null)
            {
                this.itemsSourceItems     = sourceAsListOfT;
                this.ownsItemsSourceItems = false;
                return;
            }

            this.ClearItemsSourceItems();

            if (this.ValueField == null)
            {
                this.itemsSourceItems.AddRange(this.ItemsSource.OfType <T>());
            }
            else
            {
                // Using reflection to add items by value and color (optional)
                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(this.itemsSourceItems, this.ItemsSource);
            }
        }
Ejemplo n.º 2
0
        public void Fill_InvalidProperty_ThrowsException()
        {
            var target = new List<ScatterPoint>();

            var filler = new ListFiller<ScatterPoint>();
            filler.Add("B", (p, v) => p.X = Convert.ToDouble(v));
            filler.Fill(target, this.src);
        }
Ejemplo n.º 3
0
        public void Fill_InvalidProperty_ThrowsException()
        {
            var target = new List <ScatterPoint>();

            var filler = new ListFiller <ScatterPoint>();

            filler.Add("B", (p, v) => p.X = Convert.ToDouble(v));
            filler.Fill(target, src);
        }
Ejemplo n.º 4
0
        /// <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;
        }
Ejemplo n.º 5
0
        public void Fill_NullProperty_IsIgnored()
        {
            var target = new List<ScatterPoint>();

            var filler = new ListFiller<ScatterPoint>();
            filler.Add(null, (p, v) => { });
            filler.Fill(target, this.src);

            Assert.AreEqual(1, target.Count);
            Assert.AreEqual(0, target[0].X);
        }
Ejemplo n.º 6
0
        public void Fill()
        {
            var target = new List<ScatterPoint>();

            var filler = new ListFiller<ScatterPoint>();
            filler.Add("A", (p, v) => p.X = Convert.ToDouble(v));
            filler.Fill(target, this.src);

            Assert.AreEqual(1, target.Count);
            Assert.AreEqual(3.14, target[0].X);
        }
Ejemplo n.º 7
0
        public void Fill_NullProperty_IsIgnored()
        {
            var target = new List <ScatterPoint>();

            var filler = new ListFiller <ScatterPoint>();

            filler.Add(null, (p, v) => { });
            filler.Fill(target, src);

            Assert.AreEqual(1, target.Count);
            Assert.AreEqual(0, target[0].X);
        }
Ejemplo n.º 8
0
        public void Fill()
        {
            var target = new List <ScatterPoint>();

            var filler = new ListFiller <ScatterPoint>();

            filler.Add("A", (p, v) => p.X = Convert.ToDouble(v));
            filler.Fill(target, src);

            Assert.AreEqual(1, target.Count);
            Assert.AreEqual(3.14, target[0].X);
        }
Ejemplo n.º 9
0
        /// <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;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Updates the points from the <see cref="ItemsSeries.ItemsSource" />.
        /// </summary>
        private void UpdateItemsSourcePoints()
        {
            // Use the Mapping property to generate the points
            if (this.Mapping != null)
            {
                this.ClearItemsSourcePoints();
                foreach (var item in this.ItemsSource)
                {
                    this.ItemsSourcePoints.Add(this.Mapping(item));
                }

                return;
            }

            var sourceAsListOfScatterPoints = this.ItemsSource as List <T>;

            if (sourceAsListOfScatterPoints != null)
            {
                this.ItemsSourcePoints     = sourceAsListOfScatterPoints;
                this.OwnsItemsSourcePoints = false;
                return;
            }

            this.ClearItemsSourcePoints();

            var sourceAsEnumerableScatterPoints = this.ItemsSource as IEnumerable <T>;

            if (sourceAsEnumerableScatterPoints != null)
            {
                this.ItemsSourcePoints.AddRange(sourceAsEnumerableScatterPoints);
                return;
            }

            // If DataFieldX or DataFieldY is not set, try to get the points from the ItemsSource
            if (this.DataFieldX == null || this.DataFieldY == null)
            {
                foreach (var item in this.ItemsSource)
                {
                    var point = item as T;
                    if (point != null)
                    {
                        this.ItemsSourcePoints.Add(point);
                        continue;
                    }

                    var idpp = item as IScatterPointProvider;
                    if (idpp != null)
                    {
                        this.ItemsSourcePoints.Add((T)idpp.GetScatterPoint());
                    }
                }

                return;
            }

            // Use reflection to add scatter points
            var filler = new ListFiller <T>();

            this.DefineDataFields(filler);
            filler.Fill(this.ItemsSourcePoints, this.ItemsSource);
        }
Ejemplo n.º 11
0
        /// <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;
        }