예제 #1
0
        public void Bind(IEnumerable<IFractionalTimes> winners, IFractionalTimes raceToPlot, int raceid, string horseName)
        {
            _graph.Clear();

            _distance = GetDistance(raceid);
            if (null == raceToPlot || winners.Count() <= 2)
            {
                return;
            }

            var thisHorseFractions = new StarterInfo(raceid, horseName);

            var bestRace = CreateDataSet();
            var worstRace = CreateDataSet();
            var thisRace = CreateDataSet();
            var thisHorse = CreateDataSet();
            var average = CreateDataSet();

            int textIndex = 0;

            AddFractionalPoints(bestRace, worstRace, thisRace, thisHorse, average, winners, raceToPlot, thisHorseFractions, (IFractionalTimes ft) => ft.FirstFraction(), textIndex++);
            AddFractionalPoints(bestRace, worstRace, thisRace, thisHorse, average, winners, raceToPlot, thisHorseFractions, (IFractionalTimes ft) => ft.SecondFraction(), textIndex++);

            if (_distance >= MIN_DISTANCE_WITH_VALID_THIRD_FRACTION)
            {
                AddFractionalPoints(bestRace, worstRace, thisRace, thisHorse, average, winners, raceToPlot, thisHorseFractions, (IFractionalTimes ft) => ft.ThirdFraction(), textIndex++);
            }

            AddFractionalPoints(bestRace, worstRace, thisRace, thisHorse, average, winners, raceToPlot, thisHorseFractions, (IFractionalTimes ft) => ft.FinalTime(), textIndex++);
            int count = _distance >= MIN_DISTANCE_WITH_VALID_THIRD_FRACTION ? 5 : 4;
            Plot(GetHorizontalLineDataSet(count, _y1), null, Color.White);
            Plot(bestRace, _bestRaceText, Color.Gray);
            Plot(worstRace, _worstRaceText, Color.Gray);
            Plot(thisRace, _thisRaceText, Color.Blue);
            Plot(thisHorse, _thisHorseText, Color.Red);
            Plot(average, _avgText, Color.LightGray);
            Plot(GetHorizontalLineDataSet(textIndex, 22), null, Color.White);
            _graph.Invalidate();
            _graph.XAxis1.Hidden = true;
            _graph.YAxis1.Hidden = true;
        }
예제 #2
0
        private void AddFractionalPoints(DataSet bestRace, DataSet worstRace, DataSet thisRace, DataSet thisHorse, DataSet average, IEnumerable<IFractionalTimes> winners, IFractionalTimes raceToPlot, StarterInfo thisHorseFractions, Func<IFractionalTimes, double> func, int textIndex)
        {
            double bestTime = winners.Min(func);
            double worstTime = winners.Max(func);
            double thisRaceTime = func(raceToPlot);
            double thisHorseTime = func(thisHorseFractions);
            double avg = winners.Average(func);

            if (bestTime <= 0 || worstTime <= 0 || thisRaceTime <= 0 || bestTime > worstTime)
            {
                return;
            }

            const double y2 = _y2;
            const double y1 = _y1;

            double t1 = worstTime;
            double t2 = bestTime;
            double t0 = thisRaceTime;

            _thisRaceText[textIndex] = Utilities.ConvertTimeToMMSSFifth(t0);
            _thisHorseText[textIndex] = Utilities.ConvertTimeToMMSSFifth(thisHorseTime);
            _bestRaceText[textIndex] = Utilities.ConvertTimeToMMSSFifth(bestTime);
            _worstRaceText[textIndex] = Utilities.ConvertTimeToMMSSFifth(worstTime);
            _avgText[textIndex] = Utilities.ConvertTimeToMMSSFifth(avg);

            thisRace.Tables[0].Rows.Add(thisRace.Tables[0].Rows.Count, CalculateY(t1, t2, y1, y2, thisRaceTime));
            average.Tables[0].Rows.Add(average.Tables[0].Rows.Count, CalculateY(t1, t2, y1, y2, avg));
            thisHorse.Tables[0].Rows.Add(thisHorse.Tables[0].Rows.Count, CalculateY(t1, t2, y1, y2, thisHorseTime));
            bestRace.Tables[0].Rows.Add(bestRace.Tables[0].Rows.Count, CalculateY(t1, t2, y1, y2, t2));
            worstRace.Tables[0].Rows.Add(worstRace.Tables[0].Rows.Count, CalculateY(t1, t2, y1, y2, t1));
        }