Пример #1
0
        private void OpenClassRecords()
        {
            if (_currentTrackRecords == null)
            {
                return;
            }

            var records             = _currentTrackRecords.ClassRecords.Where(x => GetCorrectRecordEntry(x) != null).OrderBy(x => GetCorrectRecordEntry(x).LapTime);
            var carRecordsViewModel = _viewModelFactory.Create <CarRecordsCollectionViewModel>();

            carRecordsViewModel.Title = "Class Records for " + _currentTrackRecords.TrackName + " (" + (_showRecordsForSession ? _currentSessionType.ToString() : "All Sessions") + ")";

            List <CarRecordViewModel> trackRecords = new List <CarRecordViewModel>(_currentTrackRecords.ClassRecords.Count);

            foreach (NamedRecordSet classRecord in records)
            {
                RecordEntryDto     record       = GetCorrectRecordEntry(classRecord);
                CarRecordViewModel newViewModel = _viewModelFactory.Create <CarRecordViewModel>();
                newViewModel.CarName       = record.CarName;
                newViewModel.ClassName     = record.CarClass;
                newViewModel.BestTime      = record.LapTime;
                newViewModel.RecordSetDate = record.RecordDate;
                newViewModel.SessionType   = record.SessionType.ToString();
                trackRecords.Add(newViewModel);
            }

            carRecordsViewModel.ChildViewModels = trackRecords;
            _windowService.OpenWindow(carRecordsViewModel, carRecordsViewModel.Title, WindowState.Normal, SizeToContent.WidthAndHeight, WindowStartupLocation.CenterOwner);
        }
Пример #2
0
        private void OpenTracksRecords()
        {
            if (_currentSimulatorRecords == null)
            {
                return;
            }

            var trackRecordsOrdered       = _currentSimulatorRecords.TrackRecords.OrderBy(x => x.TrackName);
            var simulatorRecordsViewModel = _viewModelFactory.Create <SimulatorRecordsViewModel>();

            simulatorRecordsViewModel.Title = "Track Records for " + _currentSimulatorRecords.SimulatorName + " (" + (_showRecordsForSession ? _currentSessionType.ToString() : "All Sessions") + ")";
            List <TrackRecordViewModel> trackRecords = new List <TrackRecordViewModel>(_currentSimulatorRecords.TrackRecords.Count);

            foreach (TrackRecord trackRecord in trackRecordsOrdered)
            {
                RecordEntryDto record = GetCorrectRecordEntry(trackRecord.OverallRecord);
                if (record == null)
                {
                    continue;
                }
                TrackRecordViewModel newViewModel = _viewModelFactory.Create <TrackRecordViewModel>();
                newViewModel.CarName       = record.CarName;
                newViewModel.ClassName     = record.CarClass;
                newViewModel.BestTime      = record.LapTime;
                newViewModel.RecordSetDate = record.RecordDate;
                newViewModel.TrackName     = trackRecord.TrackName;
                newViewModel.SessionType   = record.SessionType.ToString();
                trackRecords.Add(newViewModel);
            }

            simulatorRecordsViewModel.ChildViewModels = trackRecords;
            _windowService.OpenWindow(simulatorRecordsViewModel, simulatorRecordsViewModel.Title, WindowState.Normal, SizeToContent.WidthAndHeight, WindowStartupLocation.CenterOwner);
        }
Пример #3
0
        private bool Evaluate(ILapInfo lapInfo, RecordEntryDto recordEntryDto)
        {
            if (recordEntryDto == null || recordEntryDto.LapTime > lapInfo.LapTime)
            {
                return(true);
            }

            return(false);
        }
Пример #4
0
        public bool TryGetClassBestRecord(string simulatorName, string trackFullName, string className, SessionType sessionType, out RecordEntryDto recordEntry)
        {
            var simulatorSet   = _simulatorsRecords.GetOrCreateSimulatorRecords(simulatorName);
            var trackRecordSet = simulatorSet.TrackRecords.FirstOrDefault(x => x.TrackName == trackFullName);

            if (trackRecordSet == null)
            {
                recordEntry = null;
                return(false);
            }

            var carRecord = trackRecordSet.GetOrCreateClassRecord(className);

            recordEntry = carRecord.GetProperEntry(sessionType);
            return(recordEntry != null);
        }