private void AddComboBoxItem(WeekendInfo data)
        {
            ComboBoxItem cbi = new ComboBoxItem(data,
                                                (cmbRaces.Items.Count + 1) + ". " + data.Weekend.Name);

            cmbRaces.Items.Add(cbi);
        }
예제 #2
0
 public static void UpdateFrmSeason(WeekendInfo weekendData)
 {
     foreach (var item in set)
     {
         if (item.Season != null && item.Season.RaceWeekends.Contains(weekendData))
         {
             item.RefreshData();
         }
     }
 }
예제 #3
0
 public Item(int index, WeekendInfo raceWeekend, DriverStandings standing)
 {
     // TODO: Complete member initialization
     this.RaceIndex         = index;
     this.RaceName          = raceWeekend.Weekend.Name;
     this.Name              = standing.Driver.NameSurname;
     this.DriverNumber      = standing.Driver.Number;
     this.StandingAfterRace = raceWeekend.Standings[standing.Driver].Position;
     this.RacePosition      = standing.Position;
 }
예제 #4
0
        public FrmRace(WeekendInfo weekendData)
            : this()
        {
            if (weekendData == null)
            {
                throw new ArgumentNullException("Argument \"weekendData\" is null.");
            }

            this.weekendData = weekendData;
            this.weekend     = weekendData.Weekend;
        }
            private int GetFinishedRunningDrivers(WeekendInfo wd)
            {
                int count = 0;

                foreach (var item in wd.Weekend.Drivers.Keys)
                {
                    Driver d = wd.Weekend.Drivers[item];
                    if (wd.Weekend.Race.Positions.GetDriverFinalStatus(d) == RacePositionCollection.eStatus.Running)
                    {
                        count++;
                    }
                }
                return(count);
            }
예제 #6
0
        private static void OrderDriverStandingsByPointsAndAssignPosition(WeekendInfo current)
        {
            current.Standings.Sort(new DriverStandings.ByPointsSumComparer());
            for (int i = 0; i < current.Standings.Count; i++)
            {
                current.Standings[i].Position = i + 1;

                if (i > 0)
                {
                    current.Standings[i].BetterStandings    = current.Standings[i - 1];
                    current.Standings[i - 1].WorseStandings = current.Standings[i];
                }
            }
        }
예제 #7
0
        private void OpenFormWithCurrentRaceFromGrid()
        {
            if (grdRaces.SelectedCells.Count == 0)
            {
                return;
            }

            int rowIndex = grdRaces.SelectedCells[0].RowIndex;

            WeekendInfo wd = this.Season.RaceWeekends[rowIndex];

            FrmRace f = new FrmRace(wd);

            f.Show();
        }
예제 #8
0
        private static void PrepareNewStandings(WeekendInfo previous, WeekendInfo current)
        {
            current.Standings.Clear();

            if (previous == null)
            {
                return;
            }

            foreach (var item in previous.Standings)
            {
                DriverStandings newDs = CloneDriverStandingsForNewRace(item);
                current.Standings.Add(newDs);
            }
        }
예제 #9
0
        private void addRaceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Weekend w = WeekendWizard.RunNewWeekendProvider(this.Season);

            if (w != null)
            {
                WeekendInfo wd = new WeekendInfo(w);
                this.Season.RaceWeekends.Add(wd);

                //bool changed = false;
                //WeekendWizard.FillWeekendFromTelemetry(w, out changed);
                //SeasonEvaluator.ReEvaluate(this.season, this.season.RaceWeekends.Count - 1);

                RefreshData();

                FrmRace f = new FrmRace(wd);
                f.Show();
            }
        }
예제 #10
0
        public async Task<SessionResult> FetchSessionData(WeekendInfo wi)
        {
            // Keep the name around, as we'll only update it if the season ids have changed
            var res = new SessionResult { SeasonName = wi.SeasonName };

            var jSonResult = await SendHttpRequestAync(IRACING_SESSION_TIMES_URL);
            var jSonData = jSonResult.Item1;
            var cookies = jSonResult.Item2;
            var sessions = ParseJSon(jSonData);
            if (null == sessions) return res;

            // Get the season ID from the first element
            // All elements should have the same season id*
            //  - Unless maybe the season is undergoing a transition??
            //    If that's the case, then we have to filter out the sessions for the season
            //    that is closest in time, and not include the sessions in the future season.
            //    TODO:This needs to be tested.
            res.SeasonID = sessions.FirstOrDefault().HasValue(s => s.SeasonID);
            
            // When getting a fresh list of sessions, ommit the ones that are expired. 
            // It is entirely possible for a session to be determined expired because we have
            // a custom buffer to determine when to mark a session expired.
            // This will also prevent repetitive flagging for trying to update the sessions.
            res.Sessions = sessions.Where(s => !s.IsExpired).ToList();

            // To resolve the seaon name we need to scrape some HTML.
            // This is a big chunk of data, so we're only going to this once when the season id changes
            if (res.SeasonID != wi.SeasonID)
            {
                //Reuse the cookies to avoid looking them up again
                var htmlResult = await SendHttpRequestAync(IRACING_SERIES_SESSIONS_PAGE_URL, cookies);
                var htmlData = htmlResult.Item1;
                var seriesTable = ParseSeriesData(htmlData);
                res.SeasonName = seriesTable[IRACING_TOKEN_SeasonName];
            }

            return res;
        }
예제 #11
0
        private static void ReEvaluate(WeekendInfo previous, WeekendInfo current, object scoringAsObject)
        {
            AbstractScoring sc = scoringAsObject as AbstractScoring;

            ReEvaluate(previous, current, sc);
        }
예제 #12
0
        private static void UpdateNewDriverStandingsByNewRace(WeekendInfo previous, WeekendInfo current, AbstractScoring scoring, Weekend weekend, RaceSession race, Dictionary <Driver, TempData> tmp, RaceLap item)
        {
            DriverStandings prevDs = null;

            if (previous != null)
            {
                prevDs = previous.Standings[item.Driver];
            }
            if (current.Standings[item.Driver] == null)
            {
                current.Standings.Add(new DriverStandings()
                {
                    Driver = item.Driver
                });
            }
            DriverStandings newDs = current.Standings[item.Driver];

            int racePoints = GetRacePoints(item, scoring, tmp);

            weekend.Points.Add(item.Driver, racePoints);

            newDs.PointsM.Add(racePoints);

            newDs.BlackFlagsMean.Add(item.Sum(
                                         i => i.IsBlackFlagged ? 1 : 0,
                                         i => i.PreviousLapAsRaceLap
                                         ));

            if (race.Positions.GetDriverFinalStatus(item.Driver) == RacePositionCollection.eStatus.Accident ||
                race.Positions.GetDriverFinalStatus(item.Driver) == RacePositionCollection.eStatus.Retired)
            {
                newDs.CrashesCount++;
            }

            if (race.Positions.GetDriverFinalStatus(item.Driver) == RacePositionCollection.eStatus.Running)
            {
                newDs.FinishesCount++;
            }

            newDs.FinishPositionsMean.Add(item.CurrentPosition);

            newDs.LapsInLead +=
                tmp[item.Driver].LapsInLead;

            newDs.QualifyPositionsMean.Add(
                tmp[item.Driver].QualifyPosition);

            newDs.RacesCount++;
            newDs.LapsCount += item.LapNumber;

            int pos = item.CurrentPosition;

            if (pos < 2)
            {
                newDs.Top1++;
            }
            if (pos < 3)
            {
                newDs.Top2++;
            }
            if (pos < 4)
            {
                newDs.Top3++;
            }
            if (pos < 6)
            {
                newDs.Top5++;
            }
            if (pos < 11)
            {
                newDs.Top10++;
            }
            if (pos < 21)
            {
                newDs.Top20++;
            }

            newDs.PreviousWeekendStanding = prevDs;
            if (prevDs != null)
            {
                prevDs.NextWeeendStanding = newDs;
            }
        }
예제 #13
0
 public void Init(WeekendInfo weekendData)
 {
     Init(weekendData.Weekend);
     Init(weekendData.Standings);
 }
 public ComboBoxItem(WeekendInfo item, string text)
 {
     this.Item = item;
     this.Text = text;
 }