Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowHelp = true;
            //var fn = RunOpenDialog(openFileDialog1);
            openFileDialog1.ShowDialog();

            try
            {
                var      fn    = openFileDialog1.FileName;
                DateTime start = DateTime.Now;
                var      cc    = new CvsContainer(fn);
                DateTime end   = DateTime.Now;
                System.Diagnostics.Debug.WriteLine("-------------");
                System.Diagnostics.Debug.WriteLine((end - start).TotalMilliseconds);

                System.Diagnostics.Debug.WriteLine(fn);

                var sname = System.IO.Path.GetFileName(fn);
                AddToCombo(sname);

                AddSeries(sname, cc.mDTVals);
            }
            catch (Exception)
            {
                //throw;
            }
        }
Beispiel #2
0
        public SlidingAverage(CvsContainer container, int dayCount)
        {
            Name = container.Name;
            //container.Type
            var sums = new List <double>();

            var dtVals = container.mDTVals;

            var dtVals2 = new List <DTVal>(dtVals);

            if (container.Type == CvsType.Normal)
            {
                dtVals2.Reverse();
            }

            var sldCount   = dtVals2.Count - dayCount;
            var runningSum = dtVals2.Take(dayCount).Select(dtv => dtv.Val).Sum();

            sums.Add(runningSum);

            for (int i = 1; i < sldCount; i++)
            {
                var sumFstVal = dtVals2.ElementAt(i).Val;
                var sumLstVal = dtVals2.ElementAt(i + dayCount).Val;
                runningSum = runningSum - sumFstVal + sumLstVal;
                sums.Add(runningSum);
            }

            MSums = sums;
            MAvgs = sums.Select(s => s / dayCount).ToList();
            //MOATs = container.mDTVals.Skip(dayCount).Select(dtv => dtv.OADate).ToList();

            MDTVals = Enumerable.Range(dayCount, dtVals2.Count - dayCount - 1)
                      .Select(i => new DTVal()
            {
                Val    = MAvgs.ElementAt(i - dayCount),
                OADate = dtVals2.ElementAt(i).OADate
            }).ToList();

            //MDTVals = Enumerable.Range(dayCount, container.mDTVals.Count- dayCount -1)
            //    .Select(i => new DTVal() {
            //        Val    = MAvgs.ElementAt(i-dayCount),
            //        OADate = container.mDTVals.ElementAt(i).OADate
            //    }).ToList();
        }