private IList<TrackWaypoint> ParseData(TextReader dataReader) { string line; List<TrackWaypoint> points = new List<TrackWaypoint>(); while ((line = dataReader.ReadLine()) != null) { if (string.IsNullOrEmpty(line)) continue; string[] data = line.Split(','); Point position = new Point(double.Parse(data[0], CultureInfo.InvariantCulture), double.Parse(data[1], CultureInfo.InvariantCulture)); double rpm = double.Parse(data[2], CultureInfo.InvariantCulture); TrackWaypoint waypoint = new TrackWaypoint(position, rpm); points.Add(waypoint); } return points; }
private void OnTimerTick(object sender, EventArgs e) { this.currentWaypoint = points[currentIndex % points.Count]; if (currentIndex % points.Count == 0) { this.currentLapTimer.Text = TimeSpan.Zero.ToString(this.labelFormat); this.lapIndicator.Value += 1; if (this.lapIndicator.Value == 20) { this.lapTimer.Stop(); this.timer.Stop(); return; } } currentIndex++; this.AnimateCarIndiactor(this.currentWaypoint.Position); this.rpmNeedle.Value = this.currentWaypoint.Rpm / 1000; this.speedNeedle.Value = this.RpmToSpeed(this.rpmNeedle.Value); }
private void StartCarAnimation() { currentIndex = 0; this.currentWaypoint = this.Points[currentIndex]; currentIndex++; Canvas.SetLeft(this.carIndicator, this.currentWaypoint.Position.X - this.carIndicator.Width / 2); Canvas.SetTop(this.carIndicator, this.currentWaypoint.Position.Y - this.carIndicator.Width / 2); this.carIndicator.Visibility = Visibility.Visible; this.lapTimer.Stop(); this.lapTimer.Start(); this.timer.Stop(); this.timer.Start(); }