コード例 #1
0
        public void Append(Checkpoint cp, bool finish = false)
        {
            if (RiderId != cp.RiderId)
            {
                throw new ArgumentException($"Found checkpoints with different RiderIds {RiderId} {cp.RiderId}", nameof(cp));
            }

            var newLaps = Laps.Concat(new [] { Laps.LastOrDefault()?.CreateNext(cp) ?? new Lap(cp, Start) });

            UpdateFromLaps(RiderId, newLaps, finish);
        }
コード例 #2
0
        public void AddLap()
        {
            var newLap = new UserLap {
                SetupSheetID = new Guid(), LapTime = TimeSpan.Zero
            };

            if (SelectedLap == null || SelectedLap.InLap)
            {
                var lastNonInLap = Laps.LastOrDefault(x => x.InLap == false);
                if (lastNonInLap != null)
                {
                    newLap.LapNumber = lastNonInLap.LapNumber + 1;
                }
                else
                {
                    newLap.LapNumber = Laps.Count() + 1;
                }
            }
            else
            {
                newLap.LapNumber = Laps.Count() + 1;
            }
            //bump the lap number of every lap beyond the insert point.
            for (var i = newLap.LapNumber - 1; i < Laps.Count(); i++)
            {
                Laps[i].LapNumber++;
            }
            var lvm = new LapViewModel {
                Lap = newLap
            };

            Laps.Add(lvm);
            var lastOrDefault = Laps.LastOrDefault(x => x.InLap == false);

            SelectedLap = lastOrDefault;
        }
コード例 #3
0
ファイル: DriverTiming.cs プロジェクト: plkumar/SecondMonitor
        private void CheckAndOverrideBestLap(double layoutLength)
        {
            if (DriverInfo.Timing.BestLapTime == TimeSpan.Zero)
            {
                return;
            }

            if (BestLap == null)
            {
                ILapInfo newBestLap = new StaticLapInfo(Laps.Count + 1, DriverInfo.Timing.BestLapTime, false, Laps.LastOrDefault(), layoutLength, this);
                _lapsInfo.Insert(0, newBestLap);
                BestLap = newBestLap;
                LapCompleted?.Invoke(this, new LapEventArgs(newBestLap));
                return;
            }

            if (BestLap.LapTime == DriverInfo.Timing.BestLapTime)
            {
                return;
            }

            ILapInfo oldBestLap = BestLap;

            oldBestLap.OverrideTime(DriverInfo.Timing.BestLapTime);
            BestLap = Laps.Where(x => x.Completed && x.Valid && x.LapTime != TimeSpan.Zero).OrderBy(x => x.LapTime).FirstOrDefault();
            LapTimeReevaluated?.Invoke(this, new LapEventArgs(oldBestLap));
        }