Example #1
0
        public MainViewModel()
        {
            StartTime   = DateTime.Now;
            CurrentTime = StartTime;
            DispatcherTimer timer = new DispatcherTimer();

            timer.Interval = TimeSpan.FromMilliseconds(1000);
            timer.Tick    += (sender, args) =>
            {
                if (Finish)
                {
                    return;
                }
                CurrentTime = DateTime.Now;
                var count = CorrectInputKeyboardSymbolModels.Count;
                if (count < 2)
                {
                    return;
                }
                for (int i = count - 1; i >= 0; i--)
                {
                    var span = CorrectInputKeyboardSymbolModels[count - 1].Time - CorrectInputKeyboardSymbolModels[i].Time;
                    if (span.TotalMilliseconds > 5000)
                    {
                        SpeedData.Add(new DataPoint(TimeSpanAxis.ToDouble(CurrentTime - StartTime), (count - 1 - i) / span.TotalMinutes));
                        while (SpeedData.Count > 60)
                        {
                            SpeedData.RemoveAt(0);
                        }
                        break;
                    }
                }
            };
            timer.Start();
        }