示例#1
0
        /// <summary> 刷新显示最后的几条 </summary>
        public void ShowLast(List <string> collection, int xMargin = 150, int count = 600)
        {
            Func <int, double> convertFuncX = l =>
            {
                if (collection.Count < count)
                {
                    l = count - collection.Count + l;
                }

                return(((double)l / count) * xMargin + (150 - xMargin) / 2);
            };

            Func <double, double> convertFuncY = l =>
            {
                //return (50 * (l - 1848) + 0 * (2448 - l)) / (2448 - 1848);

                return(((l - 2048) / 150) * 10 + 50 / 2);
            };

            int total = collection.Count;

            int skip = total > count ? total - count : 0;

            Application.Current.Dispatcher.Invoke(() =>
            {
                var cs = collection.Skip(skip).ToList();

                List <ICurveEntitySource> collections = new List <ICurveEntitySource>();

                CardiogramCurveEntitySource entity = new CardiogramCurveEntitySource();

                for (int i = 0; i < cs.Count; i++)
                {
                    PointC point = new PointC();

                    point.X = convertFuncX(i);

                    double d;
                    bool result = double.TryParse(cs[i], out d);
                    if (result)
                    {
                        point.Y    = convertFuncY(d);
                        point.Text = DateTime.Now.AddDays(i).ToString("yyyy-MM-dd");
                        entity.Source.Add(point);
                    }
                }

                collections.Add(entity);

                this.CardiogramCollection = collections;
            });
        }
        /// <summary> 刷新显示最后的几条 </summary>
        public ICurveEntitySource ShowLast(List <string> collection, int xMargin = 150, int count = 600, int addValue = 0)
        {
            Func <int, double> convertFuncX = l =>
            {
                if (collection.Count < count)
                {
                    l = count - collection.Count + l;
                }

                return(((double)l / count) * xMargin + (150 - xMargin) / 2);
            };

            Func <double, double> convertFuncY = l =>
            {
                l = l + addValue;
                //return (50 * (l - 1848) + 0 * (2448 - l)) / (2448 - 1848);
                return(((l - 2048) / 150) * 10 + 50 / 2);
            };

            int total = collection.Count;

            int skip = total > count ? total - count : 0;

            //List<ICurveEntitySource> collections = new List<ICurveEntitySource>();



            var cs = collection.Skip(skip).ToList();

            CardiogramCurveEntitySource entity = new CardiogramCurveEntitySource();

            for (int i = 0; i < cs.Count; i++)
            {
                PointC point = new PointC();

                point.X = convertFuncX(i);

                double d;
                bool   result = double.TryParse(cs[i], out d);

                if (result)
                {
                    point.Y    = convertFuncY(d);
                    point.Text = i.ToString();;
                    entity.Source.Add(point);
                }
            }

            return(entity);
        }