/// <summary>
        /// Updates the under laying model.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="index">The index.</param>
        /// <param name="updatedData">The updated data.</param>
        protected void UpdateUnderLayingModel(string path, int index, object updatedData)
        {
            var          enumerator = ItemsSource.GetEnumerator();
            PropertyInfo yPropertyInfo;

            if (enumerator.MoveNext())
            {
                yPropertyInfo = ChartDataUtils.GetPropertyInfo(enumerator.Current, path);
                IPropertyAccessor yPropertyAccessor = null;
                if (yPropertyInfo != null)
                {
                    yPropertyAccessor = FastReflectionCaches.PropertyAccessorCache.Get(yPropertyInfo);
                }
                int i = 0;
                do
                {
                    if (i == index)
                    {
                        yPropertyAccessor.SetValue(enumerator.Current, updatedData);
                        break;
                    }

                    i++;
                }while (enumerator.MoveNext());
            }
        }
示例#2
0
        private void GetSummaryValues()
        {
            if (ItemsSource == null || string.IsNullOrEmpty(SummaryBindingPath))
            {
                return;
            }

            IEnumerator       enumerator = ItemsSource.GetEnumerator();
            PropertyInfo      summaryPropertyInfo;
            IPropertyAccessor summaryPropertyAccessor = null;

            if (SummaryValues != null)
            {
                SummaryValues.Clear();
            }
            else
            {
                SummaryValues = new List <bool>();
            }

            IList <bool> summaryValues = SummaryValues;

            if (enumerator.MoveNext())
            {
                summaryPropertyInfo = ChartDataUtils.GetPropertyInfo(enumerator.Current, SummaryBindingPath);

                if (summaryPropertyInfo != null)
                {
                    summaryPropertyAccessor = FastReflectionCaches.PropertyAccessorCache.Get(summaryPropertyInfo);
                }

                if (summaryPropertyAccessor == null)
                {
                    return;
                }

                Func <object, object> summaryGetMethod = summaryPropertyAccessor.GetMethod;

                if (summaryGetMethod(enumerator.Current) != null && summaryGetMethod(enumerator.Current).GetType().IsArray)
                {
                    return;
                }

                try
                {
                    do
                    {
                        object summaryVal = summaryGetMethod(enumerator.Current);
                        summaryValues.Add(Convert.ToBoolean(summaryVal));
                    }while (enumerator.MoveNext());
                }
                catch
                {
                }
            }
        }
示例#3
0
        internal override void GeneratePropertyPoints(string[] yPaths, IList <double>[] yLists)
        {
            IEnumerator enumerator = ItemsSource.GetEnumerator();

            if (enumerator.MoveNext())
            {
                for (int i = 0; i < UpdateStartedIndex; i++)
                {
                    enumerator.MoveNext();
                }

                // To get the type of the x value and  xGetMethod.
                PropertyInfo      xPropertyInfo     = ChartDataUtils.GetPropertyInfo(enumerator.Current, this.XBindingPath);
                IPropertyAccessor xPropertyAccessor = null;
                if (xPropertyInfo != null)
                {
                    xPropertyAccessor = FastReflectionCaches.PropertyAccessorCache.Get(xPropertyInfo);
                }
                if (xPropertyAccessor == null)
                {
                    return;
                }
                Func <object, object> xGetMethod = xPropertyAccessor.GetMethod;

                XAxisValueType = GetDataType(xPropertyAccessor, ItemsSource as IEnumerable);

                if (XAxisValueType == ChartValueType.DateTime || XAxisValueType == ChartValueType.Double ||
                    XAxisValueType == ChartValueType.Logarithmic || XAxisValueType == ChartValueType.TimeSpan)
                {
                    if (!(ActualXValues is List <double>))
                    {
                        this.ActualXValues = this.XValues = new List <double>();
                    }
                }
                else
                {
                    if (!(ActualXValues is List <string>))
                    {
                        this.ActualXValues = this.XValues = new List <string>();
                    }
                }

                // To get the yGetMethod.
                PropertyInfo      yPropertyInfo     = ChartDataUtils.GetPropertyInfo(enumerator.Current, yPaths[0]);
                IPropertyAccessor yPropertyAccessor = null;
                if (yPropertyInfo != null)
                {
                    yPropertyAccessor = FastReflectionCaches.PropertyAccessorCache.Get(yPropertyInfo);
                }
                if (yPropertyAccessor == null)
                {
                    return;
                }
                if (yPropertyAccessor == null)
                {
                    return;
                }
                Func <object, object> yGetMethod = yPropertyAccessor.GetMethod;

                if (XAxisValueType == ChartValueType.String)
                {
                    IList <string> xValue = this.XValues as List <string>;
                    do
                    {
                        object xVal = xGetMethod(enumerator.Current);
                        object yVal = yGetMethod(enumerator.Current);
                        xValue.Add(xVal != null ? (string)xVal : string.Empty);
                        YCollection.Add((IList <double>)yVal ?? new double[0]);
                        ActualData.Add(enumerator.Current);
                    }while (enumerator.MoveNext());
                    DataCount = xValue.Count;
                }
                else if (XAxisValueType == ChartValueType.Double || XAxisValueType == ChartValueType.Logarithmic)
                {
                    IList <double> xValue = this.XValues as List <double>;
                    do
                    {
                        object xVal = xGetMethod(enumerator.Current);
                        object yVal = yGetMethod(enumerator.Current);
                        XData = Convert.ToDouble(xVal != null ? xVal : double.NaN);
                        xValue.Add(XData);
                        YCollection.Add((IList <double>)yVal ?? new double[0]);
                        ActualData.Add(enumerator.Current);
                    }while (enumerator.MoveNext());
                    DataCount = xValue.Count;
                }
                else if (XAxisValueType == ChartValueType.DateTime)
                {
                    IList <double> xValue = this.XValues as List <double>;
                    do
                    {
                        object xVal = xGetMethod(enumerator.Current);
                        object yVal = yGetMethod(enumerator.Current);
                        XData = ((DateTime)xVal).ToOADate();
                        xValue.Add(XData);
                        YCollection.Add((IList <double>)yVal ?? new double[0]);
                        ActualData.Add(enumerator.Current);
                    }while (enumerator.MoveNext());
                    DataCount = xValue.Count;
                }
                else if (XAxisValueType == ChartValueType.TimeSpan)
                {
                    IList <double> xValue = this.XValues as List <double>;
                    do
                    {
                        object xVal = xGetMethod(enumerator.Current);
                        object yVal = yGetMethod(enumerator.Current);
                        XData = ((TimeSpan)xVal).TotalMilliseconds;
                        xValue.Add(XData);
                        YCollection.Add((IList <double>)yVal ?? new double[0]);
                        ActualData.Add(enumerator.Current);
                    }while (enumerator.MoveNext());
                    DataCount = xValue.Count;
                }
            }

            IsPointGenerated = true;
        }