示例#1
0
 public Race(int count)
 {
     counter = count;
     laps = new Lap[count];
     for (int i = 0; i < count; i++)
         laps[i] = new Lap();
 }
示例#2
0
 public Race(int count)
 {
     counter = count;
     laps    = new Lap[count];
     for (int i = 0; i < count; i++)
     {
         laps[i] = new Lap();
     }
 }
示例#3
0
        public void newRace(Race r)
        {
            race = r;

            drivers.Items.Clear();
            for (int i = 1; i < 21; i++)
            {
                drivers.Items.Add(r.laps[1].d[i].name);
            }
            drivers.SelectedIndex = 0;


            lap = race.counter;

            float[] t;
            string  name = race.laps[1].d[1].name;
            string  team = race.laps[1].d[1].team;

            best      = new string[21];
            bestLaps  = new int[21];
            worst     = new string[21];
            worstLaps = new int[21];
            int max = 1, min = 1;

            int[] maxs = new int[21];
            int[] mins = new int[21];
            for (int d = 1; d < 21; d++)
            {
                t = new float[lap];
                for (int c = 1; c < lap; c++)
                {
                    t[c] = new float();
                    name = race.laps[1].d[d].name;
                    team = race.laps[1].d[d].team;
                    float time = race.laps[c].getConvertedTime(name, team);
                    t[c] = time;
                    if (t[max] < t[c])
                    {
                        max = c;
                    }
                    if ((t[min] > t[c] || c == 1) && time != -1)
                    {
                        min = c;
                    }
                }
                //best[d] = new string();
                bestLaps[d] = new int();
                bestLaps[d] = min;
                best[d]     = race.laps[min].getLapTime(name, team);
                float t1 = Lap.ConvertTime(best[d]);
                if (Lap.ConvertTime(best[rmin]) > t1 && Lap.ConvertTime(best[d]) != -1)
                {
                    rmin = d;
                }
                //worst[d] = new string();
                worstLaps[d] = new int();
                worstLaps[d] = max;
                worst[d]     = race.laps[max].getLapTime(name, team);
                float t2 = Lap.ConvertTime(worst[d]);
                if (Lap.ConvertTime(worst[rmax]) < t2)
                {
                    rmax = d;
                }
            }
            lb1.Text = "Race Quickest Lap Time: " + best[rmin];
            lb2.Text = "Race Slowest Lap Time: " + worst[rmax];
        }
示例#4
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            Graphics g = drawer.CreateGraphics();

            x = drawer.Width / (lap + 1);
            y = drawer.Height / 20;

            // draw the pattern
            try
            {
                g.Clear(Color.White);

                float[] t = new float[lap];
                string  name = race.laps[1].d[drivers.SelectedIndex + 1].name;
                string  team = race.laps[1].d[drivers.SelectedIndex + 1].team;
                int     max = 1, min = 1;
                for (int c = 1; c < lap; c++)
                {
                    t[c] = new float();
                    float time = race.laps[c].getConvertedTime(name, team);
                    t[c] = time;
                    if (t[max] < t[c])
                    {
                        max = c;
                    }
                    if ((t[min] > t[c] || c == 1) && time != -1)
                    {
                        min = c;
                    }
                    //float time = t[c];
                    if (time == -1)
                    {
                        g.FillRectangle(Brushes.Red, x * c, drawer.Height - 20, x / 2, 20);
                    }
                    else
                    {
                        float p = race.laps[c].getPitTime(name, team);
                        float h = (time - Lap.ConvertTime(best[rmin]));//((float)time/t[max])
                        p /= (Lap.ConvertTime(worst[rmax]) - Lap.ConvertTime(best[rmin]));
                        h /= (Lap.ConvertTime(worst[rmax]) - Lap.ConvertTime(best[rmin]));
                        g.FillRectangle(Brushes.Blue, x * c, (drawer.Height - 10) * (1 - h) + 5, x / 2, (drawer.Height - 10) * h);
                        g.FillRectangle(Brushes.Yellow, x * c, (drawer.Height - 10) * (1 - h) + 5, x / 2, (drawer.Height - 10) * p);
                        System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat();
                        drawFormat.FormatFlags = StringFormatFlags.DirectionVertical;
                        if (dispTime.Checked)
                        {
                            using (Brush tempForeBrush = new System.Drawing.SolidBrush(Color.Black))
                                g.DrawString(race.laps[c].getLapTime(name, team), new Font("Arial", 7), tempForeBrush, x * c - 2, (drawer.Height - 10) * (1 - h) - 50, drawFormat);
                        }
                    }
                }

                dmin.Text = "Best: " + best[drivers.SelectedIndex + 1] + " (Lap" + bestLaps[drivers.SelectedIndex + 1] + ")";
                dmax.Text = "Slowest: " + worst[drivers.SelectedIndex + 1] + " (Lap" + worstLaps[drivers.SelectedIndex + 1] + ")";
                bmin.Text = "Best: " + best[rmin];
                bmax.Text = "Driver: " + race.laps[1].d[rmin].name;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
            finally
            {
                g.Dispose();
            }

            base.OnPaint(pe);
        }